Skip to content

fix(everything): iterate the transports Map with for...of, not for...in - #4768

Open
simpleqt wants to merge 1 commit into
modelcontextprotocol:mainfrom
simpleqt:fix/streamable-http-map-iteration
Open

fix(everything): iterate the transports Map with for...of, not for...in#4768
simpleqt wants to merge 1 commit into
modelcontextprotocol:mainfrom
simpleqt:fix/streamable-http-map-iteration

Conversation

@simpleqt

@simpleqt simpleqt commented Sep 6, 2026

Copy link
Copy Markdown

Summary

The SIGINT handler in src/everything/transports/streamableHttp.ts iterated the transports Map<string, StreamableHTTPServerTransport> with for (const sessionId in transports). for...in enumerates own enumerable properties of the object — a Map has none — so the shutdown loop never executed: active sessions were never closed on Ctrl-C and the "Closing transport for session …" log never appeared.

Switched to for (const [sessionId, transport] of transports), reusing the destructured transport instead of re-fetching it from the Map. Introduced in refactor commit 5de886c; still present at tip.

Testing

Static-analysis provable (for...in over a Map yields no entries). Manual repro: start npx server-everything streamableHttp, connect a client, send SIGINT — before the fix no close logs appear; after the fix each session transport closes.

for...in on a Map enumerates own enumerable properties of the object
(none), so the SIGINT shutdown loop never ran and active session
transports were never closed. Switched to for...of and reused the
destructured transport instead of re-fetching it.
Copilot AI balanced review requested due to automatic review settings September 6, 2026 17:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants