fix(mcp): use long body timeout for Streamable HTTP SSE GET stream#11874
Open
JumpLink wants to merge 1 commit intodanny-avila:mainfrom
Open
fix(mcp): use long body timeout for Streamable HTTP SSE GET stream#11874JumpLink wants to merge 1 commit intodanny-avila:mainfrom
JumpLink wants to merge 1 commit intodanny-avila:mainfrom
Conversation
The same fetch (with bodyTimeout from server config, e.g. 120s) is used for both POST and the long-lived GET SSE connection. After 120s without data undici aborts the GET body, causing 'SSE stream disconnected: AbortError' and reconnect loops that flood logs (see discussion danny-avila#11230). Use a 24h body timeout for the Streamable HTTP transport fetch so the GET SSE stream is not aborted during normal idle periods. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the log-flood / reconnect loop described in Discussion #11230: MCP servers using Streamable HTTP work in the UI, but logs are continuously filled with
SSE stream disconnected: AbortError/TypeError: terminatedand repeated "Reconnecting 1/3", "Creating streamable-http transport", "Transport closed".Cause: The Streamable HTTP client uses a single
fetch(fromcreateFetchFunction) for both POST requests and the long-lived GET that holds the SSE stream. That fetch uses an UndiciAgentwithbodyTimeout: this.timeout(e.g. 120s fromlibrechat.yaml). If no data is received on the GET response body for that period, Undici aborts the body → the client sees the stream as disconnected → reconnects → the new GET hits the same timeout again → loop.Change: Use a dedicated, much longer timeout (24h) for the fetch passed to the Streamable HTTP transport. The GET SSE connection is no longer aborted after the normal request timeout, so idle connections stay open and log spam stops. POST requests are unchanged and still complete quickly.
Testing: With multiple Streamable HTTP MCP servers (e.g. calculator, image-gen, linux) and
startup: true, before: logs showed repeated SSE disconnects and reconnects every ~2 minutes. After: connections stay up and logs are quiet until a real disconnect (e.g. server restart).Checklist (wie von LibreChat gewünscht):