Repository navigation
fix: native worker supervisor crashes when a resource attachment endpoint is rejected - #180773
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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR routes synchronous resource connection failures through the existing worker failure and termination path. Example: A private worker creation request injects resource endpoint 70000.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides a focused containment fix for a source-confirmed supervisor crash, preserves resource custody, and has no actionable findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe native worker supervisor receives private lifecycle requests, constructs child workers, attaches broker resources, and returns execution and cleanup receipts to the parent handle. flowchart LR
A[Parent worker handle] --> B[Native lifecycle supervisor]
B --> C[Child worker]
B --> D[Resource attachment client]
D --> E[Spawn broker socket]
D --> F[Existing failure and stop path]
F --> B
B --> A
Technical reviewBest possible solution: Land the existing attachment-owner containment fix while preserving child join and broker-owned cleanup settlement. Do we have a high-confidence way to reproduce the issue? Source confirms that injected endpoint 70000 reaches an unguarded connect and escaping supervisor exception on current main; this review executed no target code. Is this the best way to solve the issue? The smallest complete fix belongs in the attachment client: defer synchronous rejection through its existing failure callback until the supervisor has installed ownership and child listeners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7c831b47b82d. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +4, Tests +123. Total +127 across 3 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label 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 (3 earlier review cycles)Reviewed October 23, 2026, 2:24 AM ET / 06:24 UTC (Revision 4). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Merge current main while preserving the contributor's attachment-client fix. Assert the stable socket error code instead of Bun-specific wording, observe supervisor failures without unhandled errors, and use event-driven waits. Require child join and retained cleanup uncertainty before checking that a subsequent worker can still create, exchange a message, and stop. Fixes openclaw#180581
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…oint is rejected (openclaw#180773) * fix: native worker supervisor crashes when a resource attachment endpoint is rejected * test: normalize native supervisor error events * test: assert attachment failure across Node and Bun --------- Co-authored-by: Peter Steinberger <[email protected]>
Fixes #180581
What Problem This Solves
Fixes the shared native worker supervisor crashing when a resource attachment endpoint is rejected synchronously, taking down unrelated workers without delivering a failure to the requester.
User Impact
The affected child reports its error and joins while the supervisor remains available for other workers. Resource cleanup uncertainty remains with its existing owner. Normal production endpoints are socket paths or named pipes; no supported configuration is known to produce the malformed endpoint used by this regression. No configuration, schema, protocol, or migration changes are required.
Why This Change Was Made
attachBrokerNativeResource()callednet.connect()synchronously without containing an exception. The supervisor's close-and-rethrow catch then let the exception escape its message listener before child exit handlers were installed. The attachment client now delivers this failure through its existing failure/termination path in a microtask, after the caller installs the attachment owner and child listeners. Initial connection and startup retry use the same owner; the superseded supervisor catch is removed.The child already exists, so
create-errorwould incorrectly release parent custody as though construction had failed. The preserved sequence iscreated,error,execution-exit, thenstop-errorwhen resource cleanup cannot be confirmed. A later worker can still create, exchange a message, and stop normally.The maintainer rewrite retains Anmol Bhardwaj's (@anmol0b) production fix and original commit. It repairs the regression's runtime-specific error-text assertion by checking
RangeErrorand the rejected value70000, which both supported runtimes preserve, handles supervisor errors as test failures, removes per-wait timers, and asserts the ordered join/cleanup outcome. The single regression still exercises the real supervisor over its private port, with an actual child and task port.Production delta against merged main is +22/-18 (net +4); tests +124/-1 (net +123); docs +0/-0. The small production growth is the narrow typed catch after deleting the old rethrow wrapper; unrelated code was not removed to meet a line-count target. No additional lifecycle state, restrictions, or compatibility path was added.
Evidence
src/process/spawn-broker/resource-client.ts:116callsconnect(attachment.endpoint)without a catch. The supervisor rethrows its attachment error through the private message listener. This remains present on merged mainbfe2ff250e986a305004631f7654baaf7fa61ee3.keeps the supervisor alive when a resource attachment endpoint is rejected synchronouslysends endpoint70000to the real supervisor. On the unfixed base,connect()throwsERR_SOCKET_BAD_PORT, the supervisor errors/exits, and the event wait rejects before any successful sibling round trip. With the fix, the test requires child join, retained cleanup uncertainty, and subsequent sibling creation/message/stop. No per-wait timers, sleeps, or polling.created → error → execution-exit → stop-errorand a successful sibling round trip afterward. The contributor supplied this trace; the maintainer did not rerun it locally.14ec3d9a77bfaf0ccd6cfddf7db34ed57c050a5f, including lint, types, and the Bun lifecycle suite (9 tests; regression 135 ms; file 17.34 s, including the pre-existing 15.5 s late-attachment test). This is prior-head evidence, not proof of the rewritten head.86c162214fdf0ffd76daac70c593819491f4634c; CI run 39907219078 passed all 22 selected jobs, including lint, format, production types, test types, baseline checks, and changed tests. The lifecycle suite passed 9/9 under Bun; the new regression took 33 ms, the file 16.41 s, and its shard 17.92 s.git diff --checkpassed.The original head also has a failed
openclaw/ci-gatestatus from Security Review run 39816532173, despite successful CI and successful dependency/security-sensitive statuses. Its publisher reported that CI had not passed; this was not a security code finding. The final rewritten head has successful CI and gate results; the earlier failed status is superseded.The first maintainer head failed CI run 39905994821 for two PR-caused test issues: the Worker error event is typed
unknown(check-test-types-core-2, job120258867767), and Bun omits Node's socket error code (checks-node-changed-1, job120258372430). The repair uses the existing error normalizer and checks the error name plus offending value. All lifecycle, cleanup, and sibling assertions remain. These failures are repaired here, not classified as inherited; no CI rerun was requested.ClawSweeper's requested re-review found no actionable code findings and retained sufficient proof on
44410951a39c3972ad89cbe6ae96eda3a262e232. The two subsequent test-only corrections passed the latest Codex autoreview through P2 and the final exact-head CI above. The PR is ready for maintainer review; no merge was performed.