Repository navigation
fix(iroh-node): end the home relay watcher when the endpoint closes - #193995
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
The child now records its exit status, closes the ingress server and iroh endpoint, and releases the IPC channel so Node exits on its own, as the no-forced-process-exit guard requires (nodejs/node#64274). It relies on the iroh binding ending HomeRelayWatcher.next() when the endpoint closes (#193995).
|
Codex review: needs maintainer review before merge. What this changesThis PR ends home relay status forwarding when its endpoint closes so waiting JavaScript calls finish and Node can exit naturally. Example: A Node child consumes the initial empty relay status, starts another watcher.next(), and closes its endpoint.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides a minimal repair for a watcher-lifetime defect still present on main; the previous public-description finding is resolved, and no actionable defects remain. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe native binding forwards iroh relay statuses through a Tokio watch channel to JavaScript; endpoint closure now ends that forwarding task. flowchart LR
A[Iroh endpoint] --> B[Relay status source]
B --> C[Forwarding task]
C --> D[Tokio watch channel]
D --> E[JavaScript next call]
A --> F[Endpoint closed signal]
F --> C
Technical reviewBest possible solution: Keep the endpoint-owned cancellation scope and both native lifecycle regressions. Do we have a high-confidence way to reproduce the issue? The source and pinned dependency contract establish the failure path, and the supplied baseline run reports both lifecycle orders hanging; this review executed no target code. Is this the best way to solve the issue? The patch fixes the producer's lifetime through the existing endpoint cancellation owner and preserves the normal status-delivery path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8d922199c076. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceTests +35, Other +2. Total +37 across 4 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 6, 2026, 1:44 AM ET / 06:44 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
The child now records its exit status, closes the ingress server and iroh endpoint, and releases the IPC channel so Node exits on its own, as the no-forced-process-exit guard requires (nodejs/node#64274). It relies on the iroh binding ending HomeRelayWatcher.next() when the endpoint closes (#193995).
…relayed-device Gateway auth (#192345) * feat(openclaw-id): add the tunnel transport, OpenClaw ID sign-in and relayed-device Gateway auth * fix(openclaw-id): an HTTP request from a removed tunnel device does nothing more A relayed HTTP request kept the role it was admitted with, so a POST /tools/invoke waiting in a before-tool-call hook still ran its tool after the device was removed. Every authority check on a relayed HTTP request now asks the membership authority whether the device is still admitted with the same kind, account and role; a removal, a role change or OpenClaw ID turning off fails the next check, including the last one before the tool runs. * fix(openclaw-id): keep durable work bound to the device that authorized it Scheduled jobs, condition scripts, script payloads, shell commands, stream watchers and HTTP execution created over the tunnel now keep the original device's authority (claw, root, listing seq, owner device) with the job. Every run, restart and recovery rechecks it against the local membership record and cancels the work when the device is removed, re-approved, its role changes or the switch turns off. Recovery waits only for the local record. - WebSocket and run authority follow current membership; HTTP and WebSocket members use the canonical OpenClaw ID profile. - Stream watchers keep the process grant apart from the payload grant. - Another operator's timing edits keep the original requester; they never promote a member's job to the editor. - Restored Control UI continuations are owner-only only under admin scope. - A stopped Gateway ends local authority even during a cold first load. * test(openclaw-id): bound the ingress test WebSocket server payload * fix(openclaw-id): keep a device's scheduled grant when another device edits its timing * fix(openclaw-id): publish the token-binding writer before the tunnel admits devices * fix(gateway): keep the tunnel principal on plugin HTTP route clients * fix(gateway): never auto-approve a tunnel node by its synthetic address * test(openclaw-id): check the tunnel child exits on its own * fix(openclaw-id): keep the long-path ingress socket under the OpenClaw temp root * refactor(cron): break the stream operator source import cycle * refactor(openclaw-id): break the sign-out type cycle with the service * refactor(gateway): give the stream job scope key its own export name * fix(scripts): narrow operator source variants in the cron context replay * chore(test): allocate the OpenClaw ID tunnel regression test lines * test(gateway): give the deferred profile fixture a real auth result * test(gateway): keep real SSH verify exports in the tunnel node mock * fix(openclaw-id): let the tunnel child exit without forcing it The child now records its exit status, closes the ingress server and iroh endpoint, and releases the IPC channel so Node exits on its own, as the no-forced-process-exit guard requires (nodejs/node#64274). It relies on the iroh binding ending HomeRelayWatcher.next() when the endpoint closes (#193995). * fix(openclaw-id): require the iroh relay watcher so the tunnel child can exit A binding without HomeRelayWatcher made the child fall back to endpoint.online(), which iroh leaves pending after the endpoint closes. That pending native call kept a stopped child alive, so after the Gateway died it could hold its endpoint key indefinitely. The loader now refuses such a binding as unavailable. * fix(openclaw-id): zero the endpoint key when binding the endpoint fails * test(openclaw-id): mock node:module without spreading its class export * chore(test): allocate the OpenClaw ID tunnel test lines CI measures * fix(openclaw-id): keep the inactivity window helper private to the owner lifecycle service.ts no longer imports inactivityWindows after the owner-expiry timer moved into owner-lifecycle.ts, so the export had no consumer and failed the unused-export scan.
…relayed-device Gateway auth (openclaw#192345) * feat(openclaw-id): add the tunnel transport, OpenClaw ID sign-in and relayed-device Gateway auth * fix(openclaw-id): an HTTP request from a removed tunnel device does nothing more A relayed HTTP request kept the role it was admitted with, so a POST /tools/invoke waiting in a before-tool-call hook still ran its tool after the device was removed. Every authority check on a relayed HTTP request now asks the membership authority whether the device is still admitted with the same kind, account and role; a removal, a role change or OpenClaw ID turning off fails the next check, including the last one before the tool runs. * fix(openclaw-id): keep durable work bound to the device that authorized it Scheduled jobs, condition scripts, script payloads, shell commands, stream watchers and HTTP execution created over the tunnel now keep the original device's authority (claw, root, listing seq, owner device) with the job. Every run, restart and recovery rechecks it against the local membership record and cancels the work when the device is removed, re-approved, its role changes or the switch turns off. Recovery waits only for the local record. - WebSocket and run authority follow current membership; HTTP and WebSocket members use the canonical OpenClaw ID profile. - Stream watchers keep the process grant apart from the payload grant. - Another operator's timing edits keep the original requester; they never promote a member's job to the editor. - Restored Control UI continuations are owner-only only under admin scope. - A stopped Gateway ends local authority even during a cold first load. * test(openclaw-id): bound the ingress test WebSocket server payload * fix(openclaw-id): keep a device's scheduled grant when another device edits its timing * fix(openclaw-id): publish the token-binding writer before the tunnel admits devices * fix(gateway): keep the tunnel principal on plugin HTTP route clients * fix(gateway): never auto-approve a tunnel node by its synthetic address * test(openclaw-id): check the tunnel child exits on its own * fix(openclaw-id): keep the long-path ingress socket under the OpenClaw temp root * refactor(cron): break the stream operator source import cycle * refactor(openclaw-id): break the sign-out type cycle with the service * refactor(gateway): give the stream job scope key its own export name * fix(scripts): narrow operator source variants in the cron context replay * chore(test): allocate the OpenClaw ID tunnel regression test lines * test(gateway): give the deferred profile fixture a real auth result * test(gateway): keep real SSH verify exports in the tunnel node mock * fix(openclaw-id): let the tunnel child exit without forcing it The child now records its exit status, closes the ingress server and iroh endpoint, and releases the IPC channel so Node exits on its own, as the no-forced-process-exit guard requires (nodejs/node#64274). It relies on the iroh binding ending HomeRelayWatcher.next() when the endpoint closes (openclaw#193995). * fix(openclaw-id): require the iroh relay watcher so the tunnel child can exit A binding without HomeRelayWatcher made the child fall back to endpoint.online(), which iroh leaves pending after the endpoint closes. That pending native call kept a stopped child alive, so after the Gateway died it could hold its endpoint key indefinitely. The loader now refuses such a binding as unavailable. * fix(openclaw-id): zero the endpoint key when binding the endpoint fails * test(openclaw-id): mock node:module without spreading its class export * chore(test): allocate the OpenClaw ID tunnel test lines CI measures * fix(openclaw-id): keep the inactivity window helper private to the owner lifecycle service.ts no longer imports inactivityWindows after the owner-expiry timer moved into owner-lifecycle.ts, so the export had no consumer and failed the unused-export scan.
Related: #192345
What Problem This Solves
Fixes a Node child staying alive after its iroh endpoint closes while it is watching home relay status.
User Impact
Unblocks removing
process.exitfrom the OpenClaw ID tunnel child in #192345: pending and subsequentHomeRelayWatcher.next()calls can finish, letting the child exit naturally. This binding is not loaded by main yet. No dependency, version, lockfile, or public API shape changes.Why This Change Was Made
The relay-status forwarding task could outlive its endpoint and retain its watch sender forever. Run it under iroh 1.4.1's documented
Endpoint::closed().run_until(...)cancellation scope so closure drops the sender. Keep the existing first-status/change delivery and clarify the close promise in generated types.Reuse the endpoint's existing cancellation owner; no new state or cancellation API. Production Rust stays the same size (three lines replaced). The 35-line regression allocation covers two lifecycle orders in real Node subprocesses, asserting null completion and successful natural exit without
process.exit.Evidence
aarch64-apple-darwin), Node 24.22.1, Rust 1.99.0.b72ee38923d26c562179b8f9db7d0fa979cc42deplus only the regression: built successfully, then both pending and post-close cases failed after 10 seconds. Each child reachedendpoint closed, never reachedwatcher ended, and required the test runner's timeout termination (2 failures; 20.30 seconds).mise exec [email protected] -- npx --yes --package=@napi-rs/[email protected] -- napi build --platform --release --strip --target aarch64-apple-darwin(same invocation as the workflow).node --test --test-name-pattern="home relay watcher" test/binding.test.cjs.npm run buildattempt failed before compilation because npm could not determine the package executable; the workflow's explicitnapicommand above uses the same pinned CLI and build flags. That unrelated script remains unchanged.cargo fmt --check,cargo clippy --locked --release --all-targets -- -D warnings, the release build above, andnode --test test/binding.test.cjs: 10/10 passed, 0.580 seconds wall time. The new subprocess cases exited naturally in 68 ms / 39 ms. Both builds emitted only the existing macOS linker-s is obsoletewarning.index.d.tswas retrieved from that build;index.jsandCargo.lockremained unchanged. All four platform jobs passed, including Linux wire compatibility and throughput: https://github.com/openclaw/openclaw/actions/runs/42174068153.Reviewed and published head:
37789a6988cd4ef819ff1aec583ca76697249bd0(identical tested Rust/test bytes).