Skip to content

test(bridge): move port-discovery fixture ports out of the OS ephemeral port range - #197

Merged
Mearman merged 1 commit into
mainfrom
fix/port-discovery-eaddrinuse-flake
Sep 18, 2026
Merged

Mearman merged 1 commit into
mainfrom
fix/port-discovery-eaddrinuse-flake

Conversation

@Mearman

@Mearman Mearman commented Sep 18, 2026

Copy link
Copy Markdown
Member

Fixes the EADDRINUSE flake reported in #196: port-discovery.unit.test.ts's hardcoded
fixture ports (49000-49402) sat inside the ephemeral/dynamic port range both Linux
(default 32768-60999) and macOS (default 49152-65535) draw from when auto-assigning a
source port to an outbound connection. Any unrelated process's outbound socket could
transiently claim one of those exact port numbers at the moment a test tried to bind it
as a listening server. A prior fix (widening blockPort's own EADDRINUSE retry window)
reduced the odds but didn't close out the race, since it only covers the test's own
bind attempts, not the underlying reason the collision domain existed in the first
place.

This moves every fixture port down to the 20000s, below both platforms' ephemeral
floors, removing the collision domain outright rather than tolerating it with a wider
retry window. Adds a test asserting every fixture port stays under that ceiling (fails
against the old 49000s range, passes against the new one), and a deterministic test
proving blockPort's own retry genuinely recovers from a transient EADDRINUSE rather
than relying on that path never being exercised.

Closes #196

…al port range

port-discovery.unit.test.ts's hardcoded fixture ports (49000-49402) sat inside the
ephemeral/dynamic port range both Linux (32768-60999) and macOS (49152-65535) draw from
when auto-assigning a source port to an outbound connection. An unrelated process's
outbound socket could transiently claim one of those exact port numbers at the moment a
test tried to bind it as a listening server, producing a genuine EADDRINUSE race that a
prior retry-window widening didn't fully close out.

Move every fixture port down to the 20000s, below both platforms' ephemeral floors,
removing the collision domain outright. Add a test asserting all fixture ports stay
under that ceiling, and a deterministic test proving blockPort's own EADDRINUSE retry
recovers from a genuinely transient bind conflict rather than relying on it happening
not to occur.

Closes #196
@Mearman
Mearman marked this pull request as ready for review September 18, 2026 09:14
@Mearman
Mearman merged commit ef7ee17 into main Sep 18, 2026
6 checks passed
@Mearman
Mearman deleted the fix/port-discovery-eaddrinuse-flake branch September 18, 2026 09:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-18T09:16:52.997973Z aeceb07 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 3.17.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

port-discovery.unit.test.ts flakes with EADDRINUSE under parallel test load

1 participant