Description
Some HTTP adapters (e.g., @hono/node-server) buffer small SSE responses and automatically add a Content-Length header. When the SSE stream closes, this causes an HTTP/2 PROTOCOL_ERROR because HTTP/2 doesn't allow Content-Length with streaming responses.
Reproduction
- Use
WebStandardStreamableHTTPServerTransport with @hono/node-server over HTTP/2
- Perform an MCP operation that returns a small SSE response
- Observe
PROTOCOL_ERROR on stream close
Expected Behavior
SSE streams should work correctly over HTTP/2 without protocol errors.
Proposed Fix
Add Transfer-Encoding: chunked header to all SSE responses in WebStandardStreamableHTTPServerTransport. This prevents HTTP adapters from buffering and adding Content-Length.
Affected locations in packages/server/src/server/streamableHttp.ts:
handleGetRequest method (~line 450)
replayEvents method (~line 507)
handlePostRequest method (~line 757)
Additional Context
Reference: https://github.com/honojs/node-server/blob/main/src/listener.ts#L463-L491 (Hono's buffering logic)
Description
Some HTTP adapters (e.g.,
@hono/node-server) buffer small SSE responses and automatically add aContent-Lengthheader. When the SSE stream closes, this causes an HTTP/2PROTOCOL_ERRORbecause HTTP/2 doesn't allowContent-Lengthwith streaming responses.Reproduction
WebStandardStreamableHTTPServerTransportwith@hono/node-serverover HTTP/2PROTOCOL_ERRORon stream closeExpected Behavior
SSE streams should work correctly over HTTP/2 without protocol errors.
Proposed Fix
Add
Transfer-Encoding: chunkedheader to all SSE responses inWebStandardStreamableHTTPServerTransport. This prevents HTTP adapters from buffering and addingContent-Length.Affected locations in
packages/server/src/server/streamableHttp.ts:handleGetRequestmethod (~line 450)replayEventsmethod (~line 507)handlePostRequestmethod (~line 757)Additional Context
Reference: https://github.com/honojs/node-server/blob/main/src/listener.ts#L463-L491 (Hono's buffering logic)