@@ -274,10 +274,9 @@ export class WebStandardStreamableHTTPServerTransport implements Transport {
274274 private startKeepAlive ( streamId : string , controller : ReadableStreamDefaultController < Uint8Array > , encoder : TextEncoder ) : void {
275275 // A deferred arm (e.g. after an event-store await that straddled
276276 // close()) must not outlive the transport: close()'s timer sweep has
277- // already run. Non-finite intervals (NaN, Infinity) and non-positive
278- // ones disable keep-alive: setInterval would clamp them to ~1ms and
279- // flood every stream with comment frames.
280- if ( ! Number . isFinite ( this . _keepAliveMs ) || this . _keepAliveMs <= 0 || this . _closed ) {
277+ // already run. Invalid timer delays disable keep-alive rather than
278+ // letting setInterval clamp them to ~1ms and flood every stream.
279+ if ( ! Number . isFinite ( this . _keepAliveMs ) || this . _keepAliveMs <= 0 || this . _keepAliveMs > 2_147_483_647 || this . _closed ) {
281280 return ;
282281 }
283282 this . stopKeepAlive ( streamId ) ;
@@ -681,8 +680,8 @@ export class WebStandardStreamableHTTPServerTransport implements Transport {
681680 private async handlePostRequest ( req : Request , options ?: HandleRequestOptions ) : Promise < Response > {
682681 // Set once the SSE stream bookkeeping has been registered, so the
683682 // catch below can reclaim it: an error after registration (a failed
684- // priming event write, a throwing message handler) returns 400 and
685- // discards the Response , leaving nothing that could ever cancel the
683+ // priming event write, a throwing message handler) returns an error
684+ // response , leaving nothing that could ever cancel the discarded
686685 // stream or retire the request mappings.
687686 let reclaimSseBookkeeping : ( ( ) => void ) | undefined ;
688687 try {
0 commit comments