Repository navigation
fix(gateway): prevent shutdown hangs during suspension - #138734
Conversation
Cancel pending reconnect and startup admission waits through the owning connection scope while retaining admitted work through completion. Share the admission wait lifecycle and cover abort/resume races. Join child process closure before deleting fixture directories, await environment restoration, and align browser EOF proof with Windows process termination. Follow-up to #136146.
|
🦞👀 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. Reviewed September 4, 2026, 8:53 PM ET / September 5, 2026, 00:53 UTC. ClawSweeper reviewWhat this changesCancels reconnect and startup work still queued behind Gateway suspension when shutdown begins, preserves completion tracking for running work, and corrects related test cleanup ordering. Merge readiness✅ Ready for maintainer review Keep open: current main still contains the shutdown-blocking admission wait, and this PR provides a focused repair with meaningful regression coverage. No introduced correctness defect was found. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway admission coordinator controls when reconnect-triggered and startup background work may begin. Its connection-lifetime owner must retire queued work during shutdown while retaining running operations until their dependencies can safely close. flowchart TD
A[Operator reconnect or startup] --> B[Gateway lifetime owner]
B --> C{Admission open?}
C -->|No| D[Wait for resume or shutdown]
D -->|Resume| C
D -->|Shutdown| E[Remove waiter and settle]
C -->|Yes| F[Run callback through completion]
E --> G[Finish Gateway cleanup]
F --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +21, Tests +277, Docs +3. Total +301 across 12 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep cancellation inside the shared admission waiter while retaining admitted callbacks through completion; the small signal-plumbing increase preserves that ownership distinction without racing running work. Do we have a high-confidence way to reproduce the issue? Yes, from source: suspend admission, queue reconnect sync or a startup tail, then close the Gateway; current main's waiter cannot observe the owner's abort. Focused regression cases encode this ordering, but this read-only review did not execute them. Is this the best way to solve the issue? Yes: extending the existing admission owner is preferable to reopening suspension during shutdown or racing entire callbacks, either of which would weaken the established completion boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4d132d8cbd47. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Cancel pending reconnect and startup admission waits through the owning connection scope while retaining admitted work through completion. Share the admission wait lifecycle and cover abort/resume races. Join child process closure before deleting fixture directories, await environment restoration, and align browser EOF proof with Windows process termination. Follow-up to openclaw#136146.
What Problem This Solves
Fixes an issue where operators closing a suspended Gateway could wait until suspension expiry because background work queued by a reconnect or startup hook still held the connection lifetime open.
Related: #136146.
Why This Change Was Made
Pending independent admission now observes the owning connection scope's abort signal and removes its waiter on cancellation. The admission owner rechecks cancellation after resume; callbacks already admitted remain tracked until their original completion. Reconnect identity synchronization, restart-sentinel refresh, and
gateway_startuse the same cancellation boundary. Startup work still avoids lending its connection scope to long-lived services.The follow-up also waits for child-process close before removing fixture directories, awaits asynchronous environment restoration, and limits the browser stdin-EOF assertion to platforms where graceful stdin closure precedes process termination. Process-death assertions remain cross-platform.
User Impact
Gateway shutdown no longer waits for a suspension lease to expire merely to retire queued background work. Work already running still drains normally. The suspension documentation records that behavior. No configuration, schema, protocol, or dependency changes.
Evidence
Production: +58/-37 (net +21); tests: +294/-17 (net +277); docs: +3. The production growth carries cancellation through the existing admission owner while sharing and replacing duplicated waiter registration; racing whole callbacks would incorrectly abandon admitted work.
Windows execution was not performed locally. This follow-up does not claim acceptance of #136146's separate protected-metadata audit gap.