mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
When an SSE event went over `maxMessageBytes`, `consumeSseStream()` threw the size-limit error, but its `finally` only released the reader lock. Releasing the lock does not cancel the response body. If the server kept the response open, for example with heartbeats, the failed request held its HTTP connection until the server ended it or the whole client was closed. The same applies to the GET notification stream, which uses the same function. On error, `consumeSseStream()` now cancels the reader before it rethrows and releases the lock. A failure in `cancel()` is ignored, so the caller still gets the original error. Testing: - New test in `packages/mcp/test/streamable-http.test.ts`: it feeds an oversized event through a stream that stays open and checks that the stream's `cancel` callback runs. It fails without the change and passes with it. - Full mcp package tests: 48/48 pass. `npm run check` is clean. - Reproduction over loopback: a local `node:http` server sends a 512-byte event, then a heartbeat every 20 ms, and the client reads it through `fetch` with `maxEventBytes: 128`, three times. - Before: none of the three server responses closed, and the server made 28 more heartbeat writes. - After: all three closed, with no further writes. Fixes #11729 Requested by @badlogic Co-authored-by: triagent <triagent@localhost> |
||
|---|---|---|
| .. | ||
| agent | ||
| ai | ||
| chord | ||
| codemode | ||
| coding-agent | ||
| durable | ||
| env | ||
| evals | ||
| mcp | ||
| schema | ||
| telemetry | ||
| tui | ||