Repository navigation
Stop racing other tests for a "dead" port - #133
Merged
Merged
Conversation
Three tests bind a random port, drop the listener, and connect to the
address expecting TCP to refuse. Dropping the listener frees the port,
and this file binds a random port in seven places — several of which
then run a real SOCKS5 server. When the OS hands the freed port to one
of them, the dead proxy answers, and the test sees a handshake instead
of a refusal.
That is what CI hit on Windows:
left: Some(Stage { step: Handshake, peer: Proxy })
right: Some(Stage { step: Tcp, peer: Proxy })
error: "The proxy asks for authentication method 0x01"
Something on that port was speaking SOCKS5 — on a port the test had just
released.
`dead_port` keeps the same trick but checks it: connect once, and if
anything answers, take another port. The window is not zero, but it is
now bounded by one connect rather than by however long the test runs.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
fylorn
force-pushed
the
fix/l1-dead-port-race
branch
from
September 23, 2026 09:48
07355d8 to
bf95d9d
Compare
Merged
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.
Fixes a flaky test that surfaced on the Windows job in #132 — unrelated to that PR's contents, but it will keep hitting every PR until it is fixed.
The race
Three tests need an address where TCP connect gets refused. They bind a random port, drop the listener, and connect:
l1.rsbinds a random port in seven places, and several of those then run a real SOCKS5 server. When the OS hands the just-freed port to one of them, the "dead" proxy answers.That is exactly what CI saw:
Something was speaking SOCKS5 on a port the test had released a moment earlier. Windows hits it more often — its port allocation reuses freed ports sooner than Linux's rotation does.
The fix
dead_port()keeps the same trick but verifies it: connect once, and if anything answers, take another port. The window is not zero, but it is now bounded by a single connect rather than by the whole length of the test.Ran the
l1::tests 20× locally — green every time.🤖 Generated with Claude Code