Repository navigation
fix(gateway): bound advisory bind probes and close late listeners - #80921
Conversation
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
|
Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 7:28 PM ET / 23:28 UTC (Revision 11). ClawSweeper reviewWhat this changesBounds 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 Review scores
Verification
How this fits togetherGateway 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]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +7, Tests +80. Total +87 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest 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. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (10 earlier review cycles; latest 8 shown)
|
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper PR egg: 🎁 locked until real behavior proof passes. Details
|
|
@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. |
|
@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. |
|
@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. |
|
This pull request has been automatically marked as stale due to inactivity. |
|
Updated the PR body with the required @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
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]>
|
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 |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…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]>
What Problem This Solves
Gateway startup awaits an advisory bind probe before creating its HTTP listeners. If the temporary TCP server emits neither
listeningnorerror, 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:
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:
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
netsource 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 anECONNRESETdownloading 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), andnode 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.