Skip to content

fix: clean up STDIO sessions after disconnect#1649

Open
kmishra1204 wants to merge 1 commit into
modelcontextprotocol:mainfrom
kmishra1204:codex/stdio-session-cleanup
Open

fix: clean up STDIO sessions after disconnect#1649
kmishra1204 wants to merge 1 commit into
modelcontextprotocol:mainfrom
kmishra1204:codex/stdio-session-cleanup

Conversation

@kmishra1204

Copy link
Copy Markdown

Summary

  • remove STDIO and SSE session references when either side of the proxy closes
  • detach the STDIO STDERR listener before child-process shutdown and handle in-flight send rejections
  • add focused lifecycle tests plus an end-to-end disconnect/reconnect regression test using the real proxy and a real STDIO child
  • run the server tests in the main CI workflow without adding another test framework

Reproduction proof

The new integration test aborts the Inspector SSE connection while the STDIO child writes shutdown output to STDERR. On current main, the proxy exits with the reported SSEServerTransport.send(): Error: Not connected stack. With this change, the proxy remains healthy and accepts a second STDIO connection.

Testing

  • npm test --workspace=server (3 tests passed)
  • npm run build
  • npm run check-version
  • cd client && npm run lint
  • 31 existing client suites passed; proxyFetchEndpoint.test.ts could not bind its fixture in this Docker runner and fails identically on an untouched upstream/main snapshot

Fixes #654

Disclosure: this contribution was developed with AI assistance and validated with local red/green runtime testing.

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.

STDIO server not restarting after disconnect

1 participant