BUG-T9: Orphaned Web UI server process blocks port after MCP client disconnect or config change#110
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 52c645e441
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if stdin_closed.is_set(): | ||
| return | ||
| stdin_closed.set() | ||
| terminate_bridge_process(bridge, grace_period=5.0) |
There was a problem hiding this comment.
Preserve in-flight responses before terminating on stdin EOF
This callback force-terminates the upstream bridge as soon as stdin closes, which can kill requests that were just forwarded but not yet answered. In piped/one-shot usage (for example, writing a final JSON-RPC request and then closing stdin), on_stdin_closed runs immediately after forwarding and can terminate mcpbridge before the response is emitted, causing dropped output and a signal-style exit code instead of a normal response. Please drain pending responses (or at least close bridge.stdin first and wait briefly) before escalating to termination.
Useful? React with 👍 / 👎.
Description
Fixes
BUG-T9by preventing orphaned wrapper processes from keeping the Web UI port bound after MCP client stdin disconnects.Key changes:
on_stdin_closedcallback support torun_stdin_forwarder().terminate_bridge_process()with bounded shutdown behavior (SIGTERMthenSIGKILLfallback after grace timeout).main()to terminate the upstream bridge when stdin reaches EOF.Validation summary:
PYTHONPATH=src pytest→659 passed, 5 skippedruff check src/→ passmypy src/→ passPYTHONPATH=src pytest --cov=src/mcpbridge_wrapper --cov-report=term-missing→91.52%total coverageType of Change
Quality Gates
Before submitting, ensure all quality gates pass:
Or run individually:
make test- All tests pass with ≥90% coveragemake lint- No linting errorsmake format- Code is properly formattedmake typecheck- Type checking passesmake doccheck- Documentation is synced with DocC (if docs changed)Documentation Sync
If you modified files in
docs/, ensure corresponding DocC files are also updated:docs/installation.mdmcpbridge-wrapper.docc/Installation.mddocs/cursor-setup.mdmcpbridge-wrapper.docc/CursorSetup.mddocs/claude-setup.mdmcpbridge-wrapper.docc/ClaudeCodeSetup.mddocs/codex-setup.mdmcpbridge-wrapper.docc/CodexCLISetup.mddocs/troubleshooting.mdmcpbridge-wrapper.docc/Troubleshooting.mddocs/architecture.mdmcpbridge-wrapper.docc/Architecture.mddocs/environment-variables.mdmcpbridge-wrapper.docc/EnvironmentVariables.mdREADME.mdmcpbridge-wrapper.docc/mcpbridge-wrapper.mdTesting
Checklist