FU-P13-T8: Prevent Web UI port collision from destabilizing MCP sessions#62
Merged
SoundBlaster merged 6 commits intomainfrom Feb 16, 2026
Merged
Conversation
…n_server, add TOCTOU regression test
…ing MCP sessions (PASS)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes an unhandled
SystemExitexception from uvicorn's daemon thread when the Web UI port becomes occupied afteris_port_available()returnsTrue(TOCTOU race). Previously,run_server()caughtOSErrorbut notSystemExit(1), which uvicorn raises internally when port binding fails — this leaked as aPytestUnhandledThreadExceptionWarningin tests and as stderr noise in production.Changes:
src/mcpbridge_wrapper/webui/server.py: extendedrun_server()to also catchSystemExit, printing a clear warning to stderr and returning cleanly so the daemon thread exits without an unhandled exceptiontests/unit/test_main_webui.py: addedtest_toctou_systemexit_from_uvicorn_does_not_crash_threadtoTestPortCollisionHandling— simulates uvicorn raisingSystemExit(1)and asserts no exception propagatesType of Change
Quality Gates
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)Results:
Documentation Sync
Testing
Checklist