Skip to content

fix(server): retry Windows reserved auto ports - #632

Merged
shantur merged 2 commits into
NeuralNomadsAI:devfrom
pascalandr:fix/windows-auto-port-eacces
Aug 3, 2026
Merged

fix(server): retry Windows reserved auto ports#632
shantur merged 2 commits into
NeuralNomadsAI:devfrom
pascalandr:fix/windows-auto-port-eacces

Conversation

@pascalandr

Copy link
Copy Markdown
Contributor

Summary

  • retry an ephemeral port when an automatic listener receives Windows EACCES
  • keep explicitly configured ports strict
  • keep non-Windows EACCES behavior unchanged

Context

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

  • focused listener retry test passes
  • server typecheck passes
  • server suite: 256 passed, 4 skipped, 1 pre-existing Windows-only git-worktrees.test.ts fixture failure
  • autonomous gatekeeper review will be published as a PR comment after opening

Fixes #627

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 pascalandr left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts fixture 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

@pascalandr

Copy link
Copy Markdown
Contributor Author

@shantur LGTM

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

PR builds are available as GitHub Actions artifacts:

https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/30746347521

Artifacts expire in 7 days.
Artifacts:

  • pr-632-04d8e75a22c7ed2acdfc93d8bad99b6fc8ac5e37-tauri-macos
  • pr-632-04d8e75a22c7ed2acdfc93d8bad99b6fc8ac5e37-tauri-macos-arm64
  • pr-632-04d8e75a22c7ed2acdfc93d8bad99b6fc8ac5e37-electron-macos
  • pr-632-04d8e75a22c7ed2acdfc93d8bad99b6fc8ac5e37-tauri-windows
  • pr-632-04d8e75a22c7ed2acdfc93d8bad99b6fc8ac5e37-tauri-linux
  • pr-632-04d8e75a22c7ed2acdfc93d8bad99b6fc8ac5e37-electron-linux
  • pr-632-04d8e75a22c7ed2acdfc93d8bad99b6fc8ac5e37-electron-windows

@shantur
shantur merged commit a628fa8 into NeuralNomadsAI:dev Aug 3, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: EACCES on port 9899 due to Windows WinNAT excluded port range

2 participants