@@ -235,7 +235,7 @@ export class StreamableHTTPClientTransport implements Transport {
235235 } ) ;
236236
237237 if ( ! response . ok ) {
238- await response . body ?. cancel ( ) ;
238+ await response . text ?. ( ) . catch ( ( ) => { } ) ;
239239
240240 if ( response . status === 401 && this . _authProvider ) {
241241 // Need to authenticate
@@ -495,7 +495,7 @@ export class StreamableHTTPClientTransport implements Transport {
495495 }
496496
497497 if ( ! response . ok ) {
498- const text = await response . text ( ) . catch ( ( ) => null ) ;
498+ const text = await response . text ?. ( ) . catch ( ( ) => null ) ;
499499
500500 if ( response . status === 401 && this . _authProvider ) {
501501 // Prevent infinite recursion when server returns 401 after successful auth
@@ -568,7 +568,7 @@ export class StreamableHTTPClientTransport implements Transport {
568568
569569 // If the response is 202 Accepted, there's no body to process
570570 if ( response . status === 202 ) {
571- await response . body ?. cancel ( ) ;
571+ await response . text ?. ( ) . catch ( ( ) => { } ) ;
572572 // if the accepted notification is initialized, we start the SSE stream
573573 // if it's supported by the server
574574 if ( isInitializedNotification ( message ) ) {
@@ -603,12 +603,12 @@ export class StreamableHTTPClientTransport implements Transport {
603603 this . onmessage ?.( msg ) ;
604604 }
605605 } else {
606- await response . body ?. cancel ( ) ;
606+ await response . text ?. ( ) . catch ( ( ) => { } ) ;
607607 throw new StreamableHTTPError ( - 1 , `Unexpected content type: ${ contentType } ` ) ;
608608 }
609609 } else {
610610 // No requests in message but got 200 OK - still need to release connection
611- await response . body ?. cancel ( ) ;
611+ await response . text ?. ( ) . catch ( ( ) => { } ) ;
612612 }
613613 } catch ( error ) {
614614 this . onerror ?.( error as Error ) ;
@@ -647,7 +647,7 @@ export class StreamableHTTPClientTransport implements Transport {
647647 } ;
648648
649649 const response = await ( this . _fetch ?? fetch ) ( this . _url , init ) ;
650- await response . body ?. cancel ( ) ;
650+ await response . text ?. ( ) . catch ( ( ) => { } ) ;
651651
652652 // We specifically handle 405 as a valid response according to the spec,
653653 // meaning the server does not support explicit session termination
0 commit comments