Skip to content

fix(windows): treat a denied loopback connect like a connect timeout at startup - #8987

Merged
lidge-jun merged 1 commit into
lidge-jun:devfrom
scy7796:fix/windows-loopback-eacces-startup
Nov 21, 2026
Merged

lidge-jun merged 1 commit into
lidge-jun:devfrom
scy7796:fix/windows-loopback-eacces-startup

Conversation

@scy7796

@scy7796 scy7796 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On some Windows hosts, connecting to an unused ::1 port fails right away with connect EACCES instead of being refused. On the machine I tested, 127.0.0.1 refuses normally and ::1 can be bound, but every connect to it is denied. I have not established which component denies it (a Mihomo/Clash TUN adapter is installed).

The startup ownership probe counted that error as an unexplained transport failure. The Windows loopback bind proof added in #8920 only runs when every failure was a connect timeout, so it never ran here. observeProxyLiveness(START_OWNERSHIP_LIVENESS) returned unknown, and a service restart that needed journal recovery stopped with "Proxy ownership is unverified; startup refused". The Task Scheduler wrapper then kept restarting the child.

This change counts a failure with code: "EACCES" and syscall: "connect" the same as a connect timeout for that decision. Nothing else changes: the proof is still limited to Windows and literal loopback addresses, and it still has to bind both the exact address and the same-family wildcard. If a process is listening, the bind fails and the verdict stays unknown. The troubleshooting page (en, es) and structure/runtime.md now mention denied connects next to timeouts.

Refs #8697. That issue covered the IPv4 timeout case; this one is the same startup path with an immediate EACCES instead of a timeout.

Verification

On Windows 11 (26200), Bun 1.4.4, at d61cca122:

  • Before the change, with nothing listening on port 10199: observeStartupEndpoint returned dead for 127.0.0.1 and unknown with no bind proof for ::1. The raw error was EACCES connect EACCES ::1:10199. observeProxyLiveness with an empty OPENCODEX_HOME configured for that port returned {"kind":"unknown","live":null}.
  • After the change, the same scripts gave ::1 → dead with bindProof: true, and {"kind":"absent","live":null,"loopbackBindProven":true}.
  • With a real Bun.serve listener on ::1:10198, the result stayed unknown with bindProof: false.
  • bun test tests/server/proxy-liveness-recovery.test.ts: 31 pass. The new EACCES case fails when the source change is reverted. The new negative cases check that EACCES outside connect, or EPERM, never reaches the bind proof.
  • bun test on the other liveness and startup-owner files (tests/server/proxy-liveness*.test.ts, tests/cli/cross-home-loopback-family.test.ts, tests/cli/cli-start-owner-absence.test.ts, tests/cli/cli-client-start-fence.test.ts, tests/cli/cli-client-start-owner-e2e.test.ts): 390 pass, 3 fail. The same 3 fail with the source change reverted: F3 and F5 in proxy-liveness-owner-evidence.test.ts and one probeEndpointLiveness case in proxy-liveness.test.ts. They need a working ::1 connection, which this host blocks.
  • bun run typecheck passes. bun run structure:check passes.
  • I did not run the full bun run test, because a full run takes longer than 15 minutes on this machine. The rest is left to CI.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

🤖 Generated with Claude Code

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes
    • Windows startup checks now handle access-denied errors on loopback connections like timeouts, allowing a successful bind check to confirm that the endpoint is absent.
  • Documentation
    • Updated troubleshooting and runtime guidance to describe access-denied connection cases during startup.

…at startup

On some Windows hosts a connect to ::1 fails at once with EACCES instead of
being refused. The startup ownership probe counted that as an unexplained
failure, so the Windows loopback bind proof from lidge-jun#8920 never ran and startup
stopped with "Proxy ownership is unverified".

A connect with syscall "connect" and code EACCES now qualifies for the same
bind proof as a connect timeout. The proof still has to bind the exact address
and the same-family wildcard, so a real listener keeps the verdict unknown.

Refs lidge-jun#8697

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ✅ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

✅ 4/4 boxes ticked.

This pull request has been marked Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently.
Maintainers notified: @lidge-jun @Ingwannu

Hygiene

✅ Deterministic PR hygiene checks passed.

@github-actions
github-actions Bot marked this pull request as draft November 20, 2026 06:53
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The startup liveness check now treats EACCES from the connect syscall as eligible for the existing Windows loopback bind proof. Tests cover successful and unsuccessful proofs, platform behavior, and other error cases. The troubleshooting guides and Runtime documentation describe the added case.

Changes: Windows loopback liveness

Layer / File(s) Summary
Connect denial recovery and validation
src/server/proxy-liveness.ts, tests/server/proxy-liveness-recovery.test.ts, docs-site/src/content/docs/.../windows-loopback-startup.md, structure/runtime.md
The liveness check recognizes EACCES only when the syscall is connect. On Windows, successful bind proofs for ::1 and :: can classify the endpoint as absent. Tests verify that failed proofs, other platforms, and EACCES without the expected syscall or EPERM do not produce that result. The documentation includes denied connects in the described startup cases.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • lidge-jun/opencodex#8920: Adds the Windows loopback bind proof that this change makes eligible for connect-phase EACCES errors.

Suggested labels: bug

Merge Risk: Minimal · up to 1b297

This change lets a Windows startup recover when the host denies connects to an unused loopback port, instead of refusing to start. It keeps the existing bind-proof safeguards, and the docs and tests match the new behavior. No merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a denied loopback connect (EACCES on connect) is now handled like a connect timeout during Windows startup liveness checks. The raw summary and objectives both describ…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the main change: a denied loopback connect (EACCES on connect) is now handled like a connect timeout during Windows startup liveness checks. The raw summary and objectives both describe this change to src/server/proxy-liveness.ts, its tests, and the docs. The title is specific, uses a conventional commit prefix, and is 79 characters, which is within a reasonable length.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d61cca1 and 1b29727.

Files selected for processing: 5

  • docs-site/src/content/docs/es/troubleshooting/windows-loopback-startup.md
  • docs-site/src/content/docs/troubleshooting/windows-loopback-startup.md
  • src/server/proxy-liveness.ts
  • structure/runtime.md
  • tests/server/proxy-liveness-recovery.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@github-actions
github-actions Bot marked this pull request as ready for review November 20, 2026 15:39
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration into dev (per MAINTAINERS.md; maintainer integration, not an independent approval)

  • Exact head: 1b29727469e32bf40e0c461af1901189609180a1
  • Checks on this head: 18 passed, 11 skipped, none pending or failing (Ubuntu PR CI; Windows/macOS are covered by the next dev batch gate).
  • Review threads: none unresolved.
  • Review: gpt-6.1-terra, two rounds, final verdict PASS.
  • Regression: tests/server/proxy-liveness-recovery.test.ts passes on this head (31 pass) and fails with src/server/proxy-liveness.ts restored from dev (1 fail).

@lidge-jun
lidge-jun merged commit 7750922 into lidge-jun:dev Nov 21, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants