fix(server): retry Windows reserved auto ports - #632
Conversation
Let automatic HTTP and HTTPS listeners retry with an ephemeral port when Windows returns EACCES for the preferred port. This prevents Tauri startup from failing when a local reservation blocks 9898 or 9899. Keep explicitly configured ports strict and preserve non-Windows EACCES behavior so permission and policy errors remain visible. Add focused coverage for occupied ports, Windows EACCES, non-Windows EACCES, and explicit-port behavior. The server typecheck and targeted test pass; the full server suite retains the existing Windows git-worktrees fixture failure.
Recognize both '--http-port 9899' and '--http-port=9899' as explicit CLI configuration. This prevents the automatic fallback from silently replacing a user-selected port. Add regression coverage for both supported forms and for similarly prefixed unrelated arguments. The focused tests and server typecheck pass.
pascalandr
left a comment
There was a problem hiding this comment.
Autonomous gatekeeper review
Two independent AI gatekeepers reviewed the public PR after it was opened.
Round 1
Correctness review: one medium finding
--http-port=<n> and --https-port=<n> were not recognized as explicit arguments because the existing detection only matched standalone flags. The new fallback could therefore have silently replaced an explicitly selected equals-form port with an ephemeral port.
Requirements review: SHIP
The observable Windows startup failure is addressed independently of the unverified WinNAT attribution, and Fixes #627 is justified.
Correction
Commit 04d8e75a now recognizes both supported explicit forms:
--http-port 9899--http-port=9899
It also rejects similarly prefixed unrelated arguments. Focused regression coverage was added.
Round 2
- Correctness gatekeeper: SHIP
- Requirements gatekeeper: SHIP
- High findings: 0
- Medium findings: 0
Validation
- focused listener/CLI tests pass
- server typecheck passes
- full server suite before the gatekeeper correction: 256 passed, 4 skipped, with the known unrelated Windows
git-worktrees.test.tsfixture failure
Residual risk
Low: retry selection is covered through the decision predicate rather than an injected Fastify listen() failure. The production call site uses that predicate directly.
Final verdict: SHIP
|
@shantur LGTM |
|
PR builds are available as GitHub Actions artifacts: https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/30746347521 Artifacts expire in 7 days.
|
Summary
EACCESEACCESbehavior unchangedContext
CodeNomad already treats 9898 and 9899 as preferred rather than mandatory ports. The fallback previously handled only
EADDRINUSE, so a Windows port reservation could terminate Tauri startup before the operating system was asked for an available port.The specific WinNAT attribution in the issue remains unverified, but the observable startup failure is fixed regardless of which Windows reservation produced
EACCES.Validation
git-worktrees.test.tsfixture failureFixes #627