Skip to content

Commit d197ffb

Browse files
authored
Cannot send a chat request (#248764)
1 parent 093605a commit d197ffb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/vs/base/common/codecs/baseDecoder.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,15 @@ export abstract class BaseDecoder<
119119
}
120120
this.started = true;
121121

122-
this.stream.on('data', this.tryOnStreamData);
123-
this.stream.on('error', this.onStreamError);
122+
/**
123+
* !NOTE! The order of event subscriptions is critical here because
124+
* the `data` event is also starts the stream, hence changing
125+
* the order of event subscriptions can lead to race conditions.
126+
* See {@link ReadableStreamEvents} for more info.
127+
*/
124128
this.stream.on('end', this.onStreamEnd);
129+
this.stream.on('error', this.onStreamError);
130+
this.stream.on('data', this.tryOnStreamData);
125131

126132
// this allows to compose decoders together, - if a decoder
127133
// instance is passed as a readable stream to this decoder,

0 commit comments

Comments
 (0)