@@ -215,19 +215,25 @@ class McpHTTPHandle extends Disposable {
215
215
216
216
async send ( message : string ) {
217
217
try {
218
- await this . _requestSequencer . queue ( ( ) => {
219
- if ( this . _mode . value === HttpMode . SSE ) {
220
- return this . _sendLegacySSE ( this . _mode . endpoint , message ) ;
221
- } else {
222
- return this . _sendStreamableHttp ( message , this . _mode . value === HttpMode . Http ? this . _mode . sessionId : undefined ) ;
223
- }
224
- } ) ;
218
+ if ( this . _mode . value === HttpMode . Unknown ) {
219
+ await this . _requestSequencer . queue ( ( ) => this . _send ( message ) ) ;
220
+ } else {
221
+ await this . _send ( message ) ;
222
+ }
225
223
} catch ( err ) {
226
224
const msg = `Error sending message to ${ this . _launch . uri } : ${ String ( err ) } ` ;
227
225
this . _proxy . $onDidChangeState ( this . _id , { state : McpConnectionState . Kind . Error , message : msg } ) ;
228
226
}
229
227
}
230
228
229
+ _send ( message : string ) {
230
+ if ( this . _mode . value === HttpMode . SSE ) {
231
+ return this . _sendLegacySSE ( this . _mode . endpoint , message ) ;
232
+ } else {
233
+ return this . _sendStreamableHttp ( message , this . _mode . value === HttpMode . Http ? this . _mode . sessionId : undefined ) ;
234
+ }
235
+ }
236
+
231
237
/**
232
238
* Sends a streamable-HTTP request.
233
239
* 1. Posts to the endpoint
@@ -297,8 +303,7 @@ class McpHTTPHandle extends Disposable {
297
303
this . _attachStreamableBackchannel ( ) ;
298
304
}
299
305
300
- // Not awaited, we don't need to block the sequencer while we read the response
301
- this . _handleSuccessfulStreamableHttp ( res , message ) ;
306
+ await this . _handleSuccessfulStreamableHttp ( res , message ) ;
302
307
}
303
308
304
309
private async _sseFallbackWithMessage ( message : string ) {
0 commit comments