Skip to content

fix: Handle SSE controller closed state in error logging#795

Merged
jirispilka merged 2 commits intomasterfrom
claude/fix-apify-mcp-793-xRZty
May 6, 2026
Merged

fix: Handle SSE controller closed state in error logging#795
jirispilka merged 2 commits intomasterfrom
claude/fix-apify-mcp-793-xRZty

Conversation

@jirispilka
Copy link
Copy Markdown
Collaborator

@jirispilka jirispilka commented May 5, 2026

Added "Controller is already closed" to the soft-fail error pattern
This error has been raised in MCP SKD recently

"{"code":"ERR_INVALID_STATE","message":"Invalid state: Controller is already closed","name":"TypeError","stack":"TypeError [ERR_INVALID_STATE]: Invalid state: Controller is already closed\n at ReadableStreamDefaultController.enqueue (node:internal/webstreams/readablestream:1102:13)\n at WebStandardStreamableHTTPServerTransport.writeSSEEvent (f...[truncated]"},"msg":"[MCP Error]"}"

closes #793

claude added 2 commits May 5, 2026 15:09
WebStandardStreamableHTTPServerTransport.writeSSEEvent throws
ERR_INVALID_STATE ("Invalid state: Controller is already closed") when
the SSE ReadableStream controller was closed by client cancellation
before a queued event was flushed. The SDK forwards it to onerror.
This is client-disconnect noise, not a server fault, so route it
through the same softFail branch as the other known disconnect
patterns to avoid Mezmo error alerts (#793).

https://claude.ai/code/session_01LpjxNt1eBv8qBZcKLozmj1
@github-actions github-actions Bot added the t-ai Issues owned by the AI team. label May 5, 2026
@jirispilka jirispilka changed the title Handle SSE controller closed state in error logging fix: Handle SSE controller closed state in error logging May 5, 2026
@jirispilka jirispilka marked this pull request as ready for review May 5, 2026 18:57
@jirispilka jirispilka requested a review from MQ37 May 5, 2026 18:58
@jirispilka jirispilka merged commit 4031a79 into master May 6, 2026
16 of 17 checks passed
@jirispilka jirispilka deleted the claude/fix-apify-mcp-793-xRZty branch May 6, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-ai Issues owned by the AI team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: ERR_INVALID_STATE that appears in mezmo logs

4 participants