Repository navigation
fix(gateway): prevent queued startup work after shutdown begins - #139092
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. Reviewed September 5, 2026, 9:09 AM ET / 13:09 UTC. ClawSweeper reviewWhat this changesPrevents queued Gateway startup tasks from starting after local shutdown begins, while preserving cleanup ordering and errors from already-admitted callbacks. Merge readiness✅ Ready for maintainer review The repair remains necessary on fetched main. No blocking correctness or security defect was found in the introduced patch. Priority: P2 Review scores
Verification
How this fits togetherAfter the Gateway attaches its server, startup scheduling launches background services and preparation tasks. Shutdown must retire queued producers while keeping dependencies available until received work finishes. flowchart TD
A[Gateway startup] --> B[Queued background tasks]
B --> C[Admission and readiness waits]
C --> D{Gateway closing?}
D -->|No| E[Start background work]
D -->|Yes| F[Retire queued task]
G[Received requests finish] --> H[Clean up services]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +32, Tests +271. Total +303 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Retain the shared scheduler checks and ACP's separate dispatch checks; these additional await-boundary checks preserve cleanup ownership without introducing another cancellation framework. Do we have a high-confidence way to reproduce the issue? Yes, from source: close the Gateway while queued startup work awaits readiness, suspension, or an import and received work delays sidecar cleanup. Fetched main lacks the necessary closing checks; this review did not execute the reproduction. Is this the best way to solve the issue? Yes, for the stated local-shutdown boundary: checking producer eligibility preserves the existing drain-before-cleanup contract. Moving teardown earlier or cancelling already-admitted operations would change that contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f09c139f3c62. 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.
|
* commit '3e4becea5e2ce38ede69e8ecf5302805ecbfc09c': refactor: simplify outbound message execution context (openclaw#139107) fix(models): keep ordinary chat selections session-scoped (openclaw#139232) docs: slim root agent instructions and clarify testing scope (openclaw#139236) test(agents): give the sibling-drain completion wait a tolerance on slow runners (openclaw#139176) refactor(workboard): use canonical queries for card-tree writes (openclaw#139106) fix(canvas): recognize versioned macOS nodes (openclaw#138958) fix: load GitHub connections without a default agent (openclaw#139222) fix(memory): explain unsafe legacy host-event path recovery (openclaw#139195) refactor(talk): centralize typed voice session queries (openclaw#139103) fix(cli): preserve command dispatch and structured errors (openclaw#139067) refactor(agents): consolidate reply failure summaries (openclaw#139175) fix(auth): keep an unset default model unchanged during login (openclaw#139218) perf(media): reuse validated attachment read handles (openclaw#139168) refactor(channels): simplify account configuration updates (openclaw#139096) refactor(android): remove unused updater export root (openclaw#139198) fix(gateway): stop admitting post-ready producers during close (openclaw#139092) fix(gateway): expose agent hook completion outcomes (openclaw#139155) fix(config): return the saved configuration after plugin install commits (openclaw#139203) fix(android): reduce repeated retries to unreachable gateways (openclaw#138732)
…law#139092) (cherry picked from commit 426ca0d)
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
Resolves a problem where stopping or restarting a newly started Gateway could still start queued background work or emit avoidable startup-failure warnings after local shutdown began, while existing requests were finishing. A callback paused for admission, a module import, or ACP backend readiness could resume into the closing Gateway.
Why This Change Was Made
The post-ready producer owner now carries the Gateway's existing live closing predicate through scheduling, admitted callback entry, and asynchronous import/catalog boundaries, preventing unstarted producers from entering after close wins. Cleanup remains with its existing lifecycle owner after received work drains; already-entered work stays owned, and real errors from admitted callbacks remain visible.
User Impact
Queued Gmail watcher/model validation, transcript auto-start, internal startup hooks, restart wake, and Control UI preparation respect local Gateway closing state. ACP identity reconciliation does not begin when close wins during admission, backend readiness, or manager loading; a scan that has already entered retains its existing completion behavior.
There are no config, protocol, database, timeout, or teardown-order changes. This does not change the earlier process-manager restart-drain-only interval or promise to cancel every operation already in progress.
Evidence
SOURCEMAP_BROKEN, and browsernode:pathwarnings; these are not described as warning-free results. Managed Codex review returned seven scoped passes with no actionable P0–P2 findings; the reviewer did not execute project code.health({probe:false}),status,tts.providers, andplugins.listin that order, followed by normal SIGTERM shutdown. Full decoded results and initial refusal/503/pre-ready-timeout observations were retained. The smoke recorded 22 INFO messages without warnings/errors; root verified all eight observed PIDs, four groups, and the listener closed. It does not reproduce the controlled close races or establish real-provider/ACP/channel race behavior. The zero-session status was a point-in-time observation before later background bindings, and none of the recorded durations is a latency comparison.Production is +37/−5, net +32 lines; tests are +321/−50, net +271 lines. The production growth propagates an existing lifecycle fact into previously unguarded producer boundaries, including ACP's distinct dispatch path, without adding a new cancellation framework. The immediate scheduler also removes its duplicate stopped flag; timer error handling preserves the distinction between actual stop and an admitted callback failing during close.
Candidate commit
cb4ccc8d50a887df0201860d38e2f67c27ac11f6preserves the exact reviewed and tested patch against base17b0c435dd5b341d645703c04354706a1c7f9a55. A source-only comparison with current main4cb260cd132f1315fccecc8c9dcb765d3ccd1f28found both touched baseline files unchanged and all 53 selected contracts identical to the context supplied to review. The eight accounted-for context changes include host lifecycle types, prepared session facts, ACP initialization cleanup, transcript retry identity, and update-notice ownership. This is not current-main runtime or CI proof. Full source, failures, closures, gate/build logs, and built-smoke readback remain under the retainedpost-ready-producer-fenceevidence family.