File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -143,16 +143,17 @@ class EventStream extends EventEmitter {
143
143
parseEventStreamLine ( pos , fieldLength , lineLength ) {
144
144
if ( lineLength === 0 ) {
145
145
try {
146
- if ( this . data . length > 0 && this . eventName ) {
146
+ if ( this . data . length > 0 && this . event ) {
147
147
const event = JSON . parse ( this . data ) ;
148
- event . name = this . eventName ;
148
+ event . name = this . eventName || '' ;
149
149
if ( this . eventName !== 'event' ) {
150
150
this . emit ( this . eventName , event ) ;
151
151
}
152
152
this . emit ( 'event' , event ) ;
153
153
this . data = '' ;
154
154
}
155
155
this . eventName = undefined ;
156
+ this . event = false ;
156
157
} catch ( e ) {
157
158
// do nothing if JSON.parse fails
158
159
}
@@ -173,6 +174,7 @@ class EventStream extends EventEmitter {
173
174
this . data += value + '\n' ;
174
175
} else if ( field === 'event' ) {
175
176
this . eventName = value ;
177
+ this . event = true ;
176
178
} else if ( field === 'id' ) {
177
179
this . lastEventId = value ;
178
180
} else if ( field === 'retry' ) {
You can’t perform that action at this time.
0 commit comments