Make managed server port allocation atomic - #204
Merged
Conversation
ccomb
added a commit
that referenced
this pull request
Jul 14, 2026
## Summary Follow-up to the post-merge review of #204. - `_await_bound_port` now lets the reader thread do the parsing and relies on `thread.join(timeout)`: the engine's death closes stdout and ends the thread, so the queue, the manual deadline loop and the `process.poll()` check were three error paths for the same condition. Same guarantees, a third less code. - A non-numeric `VOLCA_PORT=` value now raises the same clear `RuntimeError` as an out-of-range one, instead of leaking a bare `ValueError`. Covered by a new test parameter. - The `--port` help text and the changelog now say that port 0 binds the loopback interface only — Warp's `openFreePort` binds 127.0.0.1, unlike the fixed-port path which listens on all interfaces. Without this note the narrower bind is a silent behavior difference. ## Verification - pyvolca: 233 passed, 7 skipped - pyright on `server.py`: 0 errors, 0 warnings
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.
Summary
openFreePortServer(port="auto")to pyvolca while preserving existingport=0semanticsWhy
The canonical converter previously probed and released a free port before starting VoLCA. Another local process could claim that port and impersonate the engine. This change removes the TOCTOU at its source.
Verification
openFreePort/runSettingsSocketintegration type-checked locally