Skip to content

fix(gateway): bound advisory bind probes and close late listeners - #80921

Merged
fuller-stack-dev merged 3 commits into
openclaw:mainfrom
leegisang:fix/can-bind-to-host-timeout
Sep 17, 2026
Merged

fuller-stack-dev merged 3 commits into
openclaw:mainfrom
leegisang:fix/can-bind-to-host-timeout

Conversation

@leegisang

@leegisang leegisang commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gateway startup awaits an advisory bind probe before creating its HTTP listeners. If the temporary TCP server emits neither listening nor error, that await never settles. This was reported on macOS 11 Big Sur in #80920; that OS-specific trigger has not been independently reproduced here.

Fix

Integrate the existing timeout proposal with current main while retaining @leegisang's contributor ancestry. Only the probe owner and its colocated tests change relative to main:

  • Bound each advisory bind probe to three seconds.
  • Use one completion path to clear the deadline, close the temporary server and settle the result.
  • Keep the late-listening cleanup handler: a socket arriving after timeout is closed, and cannot change the already-settled result.
  • Treat synchronous listen failure like an asynchronous unavailable-address result.
  • Preserve required listen hosts, the Windows IPv6 skip, custom/container/tailnet selection and all current authorization helpers. No configuration or environment knob is added.

Release note: Gateway startup no longer waits indefinitely on an unresponsive advisory bind probe; ordinary IPv4/IPv6 loopback behavior is preserved. Original fix/report credit: Gisang Lee (@leegisang).

Evidence

Owner-boundary regression on Node 24.20.0/macOS:

  • Current-main baseline: 142 net tests passed.
  • Before repair, added lifecycle coverage: 3 failed / 1 passed. The silent probe remained pending at 3000 ms; error cleanup and synchronous-failure settlement also failed.
  • After repair: all 147 net tests passed, including never-emitting, real late-socket cleanup, error/listening ordering, synchronous listen failure, ordinary loopback, Windows skip, required hosts and existing networking/auth classification.

Real-timer, real-socket trace through the production resolvers (not a full live Gateway):

{"scenario":"silent advisory IPv6 bind","elapsedMs":3002,"hosts":["127.0.0.1"]}
{"scenario":"late real TCP bind","listening":false,"address":null}
{"scenario":"HTTP startup after resolver timeout","status":200}
{"scenario":"ordinary native loopback","hosts":["127.0.0.1","::1"],"node":"v24.20.0","platform":"darwin","bigSur":"unobserved"}

The fault is injected at the temporary server's listen boundary. The actual resolver, its deadline, late real TCP bind, and subsequent ephemeral HTTP listener execute. No operator Gateway was restarted or changed. Installed Node net source was inspected for close-before-listen and pending-lookup invalidation semantics.

Remaining proof gap: no macOS 11 Big Sur machine is attached; these results are owner-boundary fault-injection and ordinary native networking evidence, not an observed Big Sur recovery. This supplies the equivalent production-boundary harness requested by the prior review without claiming OS-specific proof.

Independent P0–P2 autoreview passed on the final candidate. An initial CI run caught test-only lint issues (spy references and an implicit Promise-executor return); these were corrected without changing production behavior. The final local lint, all 147 net tests, and the targeted gateway-root test-type graph pass.

Review disposition

The prior stale-snapshot/security concern is addressed by integrating current main rather than transplanting the old net module. Required-listener and authorization exports remain unchanged. All prior proof requests are addressed by the failing/passing lifecycle regressions and the explicit real-time trace above; exact Big Sur proof remains unobserved.

Production LOC: +15/-8 (net +7); tests: +81/-1. The small production growth supplies the missing deadline lifecycle and synchronous-failure settlement; no new abstraction or public API was introduced.

Fixes #80920

Maintainer risk disposition

The fresh ClawSweeper review accepts the production-boundary proof and reports no code or security findings. We accept the generic bounded-probe lifecycle repair with the explicit Big Sur limitation above; this is not a claim that the reported OS-specific trigger or a blocked native syscall has been repaired. The PR title reflects that scope. Required listener and authentication policy stays unchanged, so no new configuration, migration, or security decision is introduced. The final follow-up commit only fixes test lint; production source and the real-socket trace remain identical.

Final verification

Published head: c07b3b7e9258305efdc3bf8ffc897a5439180d99. CI run 35161734863, attempt 2 is green. The first attempt had 147 successful jobs; its only underlying failure was an ECONNRESET downloading the Matrix SDK native library during setup, followed by the dependency downloader error handler. Only that job and dependent gates were retried; successful jobs were reused. The corrected job 105021499390 passed at 23:56:26Z. No source or dependency change was needed for that transient setup failure.

Local commands: node scripts/run-vitest.mjs src/gateway/net.test.ts (147 passed), node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/gateway/net.test.ts src/gateway/net.ts (0 errors), and node scripts/run-tsgo-core-test-shards.mjs --changed-paths-json '["src/gateway/net.test.ts"]' (gateway-root passed). Required changed-file guards and independent final autoreview passed. Big Sur-specific behavior remains unobserved, as stated above.

On macOS 11.x (Big Sur), net.createServer().listen(0, '::1') may
never fire either 'listening' or 'error' when IPv6 loopback is
not configured. Without a timeout canBindToHost() blocks forever,
hanging resolveGatewayListenHosts() and preventing gateway startup.

Add a 3-second timeout that resolves the probe to false if neither
event fires, so startup falls back to IPv4-only binding.

Closes openclaw#80920
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 12, 2026
@clawsweeper

clawsweeper Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 7:28 PM ET / 23:28 UTC (Revision 11).

ClawSweeper review

What this changes

Bounds Gateway address probes to three seconds, closes temporary listeners after late completion, and adds lifecycle regression coverage.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused repair: current main and the latest release still lack the probe deadline. No actionable correctness or security findings remain, and the supplied production-boundary proof supports the revised scope.

Priority: P2
Reviewed head: c07b3b7e9258305efdc3bf8ffc897a5439180d99

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful lifecycle coverage and sufficient production-boundary proof; no blocking patch findings remain.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The captured Node 24.20.0/macOS trace exercises the production resolvers with an injected silent probe, real timers, a late real TCP listener, and subsequent HTTP 200 recovery; the final commit leaves production code unchanged. This proves the scoped lifecycle repair, not the unobserved Big Sur trigger or recovery from a blocked native syscall.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured Node 24.20.0/macOS trace exercises the production resolvers with an injected silent probe, real timers, a late real TCP listener, and subsequent HTTP 200 recovery; the final commit leaves production code unchanged. This proves the scoped lifecycle repair, not the unobserved Big Sur trigger or recovery from a blocked native syscall.
Evidence reviewed 8 items Focused production change: The complete network module retains existing bind modes, Windows IPv6 handling, required listen hosts, and authorization helpers. The introduced production hunk changes only the private probe lifecycle.
Still necessary on current main: Current main still resolves the probe only on error or listening, with no deadline; comparison against the reviewed head isolates the same lifecycle hunk supplied by the introduction evidence.
Latest release retains the unbounded probe: The supplied latest release, v2026.9.4, also contains the event-only probe without timeout or synchronous-failure handling.
Findings None None.
Security None None.

How this fits together

Gateway startup checks address availability before creating its HTTP listeners. These advisory probes feed bind-address selection while required listeners and authentication remain enforced by the existing startup owners.

flowchart TD
  A[Gateway bind configuration] --> B[Address selection]
  B --> C[Temporary TCP probe]
  C --> D{Listening, error, or deadline}
  D --> E[Close temporary listener]
  E --> F[Available address result]
  F --> G[Required listener and security checks]
  G --> H[Gateway HTTP listeners]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +7, Tests +80. Total +87 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 15 8 +7
Tests 1 81 1 +80
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 96 9 +87

Review metrics

None.

Technical review

Best possible solution:

Keep the deadline and late-listener cleanup in the existing probe owner while preserving required binds and describing the result as generic lifecycle recovery.

Do we have a high-confidence way to reproduce the issue?

Yes for the generic lifecycle defect: a probe emitting neither terminal event leaves current main's resolver pending indefinitely. This review did not execute target code or reproduce the reported Big Sur condition.

Is this the best way to solve the issue?

Yes. The repair stays inside the existing probe owner, preserves the fallback contract, and retains cleanup for late listeners without adding configuration or competing APIs.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8d823fa50ce9.

Labels

Label justifications:

  • P2: This is a bounded startup-reliability repair for silent advisory probes, with the original OS-specific trigger still unobserved.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The captured Node 24.20.0/macOS trace exercises the production resolvers with an injected silent probe, real timers, a late real TCP listener, and subsequent HTTP 200 recovery; the final commit leaves production code unchanged. This proves the scoped lifecycle repair, not the unobserved Big Sur trigger or recovery from a blocked native syscall.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured Node 24.20.0/macOS trace exercises the production resolvers with an injected silent probe, real timers, a late real TCP listener, and subsequent HTTP 200 recovery; the final commit leaves production code unchanged. This proves the scoped lifecycle repair, not the unobserved Big Sur trigger or recovery from a blocked native syscall.

Evidence

What I checked:

  • Focused production change: The complete network module retains existing bind modes, Windows IPv6 handling, required listen hosts, and authorization helpers. The introduced production hunk changes only the private probe lifecycle. (src/gateway/net.ts:358, c07b3b7e9258)
  • Still necessary on current main: Current main still resolves the probe only on error or listening, with no deadline; comparison against the reviewed head isolates the same lifecycle hunk supplied by the introduction evidence. (src/gateway/net.ts:358, 8d823fa50ce9)
  • Latest release retains the unbounded probe: The supplied latest release, v2026.9.4, also contains the event-only probe without timeout or synchronous-failure handling. (src/gateway/net.ts:358, 3a9d69db306c)
  • Production-boundary proof: The captured PR body at sourceRevision f108a3d3f7b37460c2e9f25dd0907053ed433cb1ea4c22001944f955190381e5 reports the actual resolvers on Node 24.20.0/macOS returning IPv4 after 3002 ms, closing a late real TCP listener, and allowing a subsequent ephemeral HTTP listener to return 200. It also records ordinary IPv4/IPv6 success and explicitly excludes an observed Big Sur recovery. The MEMBER comment corroborates the harness scope: fix(gateway): bound advisory bind probes and close late listeners #80921 (comment). (src/gateway/net.ts:358, 3cd1f9eda85e)
  • Re-review continuity: GitHub's exact-head commit patch contains only test spy/lint adjustments. Reading the previous reviewed production source confirms the lifecycle implementation is unchanged, so its supplied real-socket proof remains applicable. The prior stale-module concern is absent from the complete pinned introduced delta. (src/gateway/net.test.ts:374, c07b3b7e9258)
  • Dependency cleanup contract: The patch directly calls Node's net.Server.close, making this dependency contract relevant. Node v24.20.0 close increments the listening generation, closes and clears an existing handle, and does not throw merely because no handle exists when called without a callback; pending lookup callbacks reject an obsolete generation. The tag resolves to the cited commit. (lib/net.js:2810, 71b8b174857e)

Likely related people:

  • fuller-stack-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-01T02:04:16.284Z sha 689cbb3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-06T05:49:03.824Z sha 689cbb3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-06T06:31:23.739Z sha 689cbb3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-14T19:23:37.730Z sha 689cbb3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-15T23:25:10.010Z sha 689cbb3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-16T00:38:43.168Z sha 689cbb3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-18T01:28:59.443Z sha 689cbb3 :: needs real behavior proof before merge. :: [P1] Rebase the timeout onto current main
  • reviewed 2026-09-16T23:13:57.310Z sha 3cd1f9e :: blocked before merge. :: none

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label May 27, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels May 27, 2026
@clawsweeper

clawsweeper Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg: 🎁 locked until real behavior proof passes.

Details
  • No creature or rarity is rolled until proof passes.
  • Eggs are collectible flavor only; they do not affect labels, ratings, merge decisions, or automation.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label May 28, 2026
@clawsweeper

clawsweeper Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

@leegisang thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward.

Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive.

Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it.

@clawsweeper

clawsweeper Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

@leegisang thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward.

Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive.

Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 15, 2026
@clawsweeper

clawsweeper Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

@leegisang thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward.

Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive.

Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added stale Marked as stale due to inactivity triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 29, 2026
@leegisang

Copy link
Copy Markdown
Contributor Author

Updated the PR body with the required What Problem This Solves and Evidence sections. The Real behavior proof workflow is now passing.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jul 30, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Aug 18, 2026
@fuller-stack-dev fuller-stack-dev self-assigned this Sep 16, 2026
Integrate current main while preserving the original contributor history. Bound advisory probes to three seconds, clean up late binds, and cover silent/error/listening/synchronous failures plus real loopback sockets.

Co-authored-by: Gisang Lee <[email protected]>
@fuller-stack-dev fuller-stack-dev changed the title fix(net): add 3s timeout to canBindToHost to prevent Big Sur startup hang fix(gateway): bound advisory bind probes and close late listeners Sep 16, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member

Integrated current main with contributor ancestry preserved in 3cd1f9e. The PR body now contains failing/passing production-owner regression results and a real-time, real-socket after-fix trace. All 147 net tests pass; independent P0–P2 autoreview is scoped-clean. Current authorization helpers and required-listener behavior are unchanged.

The exact Big Sur trigger/recovery remains unobserved; the evidence is explicitly an authorized owner-boundary fault-injection harness, not a claimed Big Sur run or full live Gateway.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 16, 2026
@fuller-stack-dev
fuller-stack-dev merged commit 73d85d9 into openclaw:main Sep 17, 2026
396 of 399 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…enclaw#80921)

* fix(net): add timeout to canBindToHost to prevent hang on macOS Big Sur

On macOS 11.x (Big Sur), net.createServer().listen(0, '::1') may
never fire either 'listening' or 'error' when IPv6 loopback is
not configured. Without a timeout canBindToHost() blocks forever,
hanging resolveGatewayListenHosts() and preventing gateway startup.

Add a 3-second timeout that resolves the probe to false if neither
event fires, so startup falls back to IPv4-only binding.

Closes openclaw#80920

* test(gateway): retain bind probe spy handles for lint

---------

Co-authored-by: Jason (Json) <[email protected]>
Co-authored-by: Gisang Lee <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway hangs indefinitely on macOS Big Sur: canBindToHost("::1") has no timeout in net.ts

2 participants