Skip to content

BUG-T9: Orphaned Web UI server process blocks port after MCP client disconnect or config change#110

Open
SoundBlaster wants to merge 8 commits intomainfrom
feature/BUG-T9-orphaned-webui-process-clean-exit
Open

BUG-T9: Orphaned Web UI server process blocks port after MCP client disconnect or config change#110
SoundBlaster wants to merge 8 commits intomainfrom
feature/BUG-T9-orphaned-webui-process-clean-exit

Conversation

@SoundBlaster
Copy link
Owner

Description

Fixes BUG-T9 by preventing orphaned wrapper processes from keeping the Web UI port bound after MCP client stdin disconnects.

Key changes:

  • Added on_stdin_closed callback support to run_stdin_forwarder().
  • Added terminate_bridge_process() with bounded shutdown behavior (SIGTERM then SIGKILL fallback after grace timeout).
  • Wired a one-shot stdin-closed callback in main() to terminate the upstream bridge when stdin reaches EOF.
  • Added/updated unit tests for EOF callback invocation, termination fallback behavior, and main-loop callback wiring.
  • Completed FLOW artifacts for BUG-T9 (PRD, validation report, review report, archive index updates).

Validation summary:

  • PYTHONPATH=src pytest659 passed, 5 skipped
  • ruff check src/ → pass
  • mypy src/ → pass
  • PYTHONPATH=src pytest --cov=src/mcpbridge_wrapper --cov-report=term-missing91.52% total coverage

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactoring
  • CI/CD improvement

Quality Gates

Before submitting, ensure all quality gates pass:

make check

Or run individually:

  • make test - All tests pass with ≥90% coverage
  • make lint - No linting errors
  • make format - Code is properly formatted
  • make typecheck - Type checking passes
  • make 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/ file DocC file
docs/installation.md mcpbridge-wrapper.docc/Installation.md
docs/cursor-setup.md mcpbridge-wrapper.docc/CursorSetup.md
docs/claude-setup.md mcpbridge-wrapper.docc/ClaudeCodeSetup.md
docs/codex-setup.md mcpbridge-wrapper.docc/CodexCLISetup.md
docs/troubleshooting.md mcpbridge-wrapper.docc/Troubleshooting.md
docs/architecture.md mcpbridge-wrapper.docc/Architecture.md
docs/environment-variables.md mcpbridge-wrapper.docc/EnvironmentVariables.md
README.md mcpbridge-wrapper.docc/mcpbridge-wrapper.md
  • Documentation changes are synced with DocC catalog (or N/A)

Testing

  • Added/updated tests for new functionality
  • All tests pass locally
  • Manually tested the changes

Checklist

  • Code follows the project's style guidelines
  • Self-review completed
  • Comments added for complex code
  • Documentation updated (if needed)
  • No new warnings generated
  • PR title is descriptive

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines 484 to 487
if stdin_closed.is_set():
return
stdin_closed.set()
terminate_bridge_process(bridge, grace_period=5.0)

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

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.

1 participant