Repository navigation
refactor(runtime): share cleanup deadline waiting - #139953
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 6, 2026, 5:07 AM ET / 09:07 UTC. ClawSweeper reviewWhat this changesShares deadline waiting across tool-server and subprocess cleanup, clearing the language-server grace timer when shutdown replies early. Merge readiness✅ Ready for maintainer review This remains a useful, focused follow-up: current main retains the duplicated waits, and the pinned patch has no actionable correctness or security findings. The prior review’s empty finding list remains appropriate. Priority: P3 Review scores
Verification
How this fits togetherOpenClaw shuts down MCP tool servers, LSP language servers, and owned subprocesses through their lifecycle owners. Deadline waits bound shutdown phases; the owners separately determine whether cleanup actually completed. flowchart TD
A[Tool server shutdown] --> B[Protocol lifecycle owner]
C[Subprocess shutdown] --> D[Process lifecycle owner]
B --> E[Shared deadline wait]
D --> E
E --> F[Completed or timed out]
F --> G[Owner checks cleanup or escalates]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -12. Total -12 across 4 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep one internal deadline helper while preserving protocol shutdown ordering and owner-confirmed cleanup outcomes. Do we have a high-confidence way to reproduce the issue? Not applicable to this refactor; source inspection confirms the duplicate waits and the old LSP timer surviving an early reply. Is this the best way to solve the issue? Yes. Extracting the existing waiter is a narrow consolidation, and clearing its timer does not replace the callers’ cleanup checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9f089d6527cc. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
Related: #135868, #139517, #139657
What Problem This Solves
MCP and owned stdio duplicated the same cleanup deadline implementation, while LSP kept a third grace timer alive after an early shutdown reply. This is the maintainer-requested production compression follow-up for concern C of the #135868 split.
Why This Change Was Made
Use one internal
settlesWithinhelper for all three waits. It returns false on timeout, propagates rejection, unrefs and clears its timer. It does not decide whether resources are closed: protocol owners and the process owner's extinction join retain those decisions. LSP keeps its 500 ms shutdown grace and subsequent owned-process cleanup.User Impact
No change to shutdown budgets, escalation order, error propagation or cleanup evidence. The losing LSP grace timer is now cleared after an early reply. Production shrinks by 12 lines; tests, tooling and docs are unchanged. No public API, dependency or configuration changes.
Evidence
Existing boundary coverage is retained:
src/agents/mcp-stdio-transport.test.ts:195,218covers failed cleanup replay and confirmed/unconfirmed forced shutdown;src/agents/agent-bundle-lsp-runtime.test.ts:544,575,651covers descendant joining, uncertainty, and shutdown ordering.src/process/owned-stdio.real.test.ts:4uses a real process and drains 8,192 Unicode diagnostic lines before cleanup completes;src/process/owned-stdio.test.ts:11covers startup cleanup outcomes. The full MCP runtime suite also covers hung shutdown and remote transports.Validation: 163 focused tests passed across six suites; full
node scripts/check-changed.mjsexited 0, including core and all core-test typechecks, lint, guards, and dead-export scans. Import-cycle check: zero runtime value cycles. Independent Codex autoreview against the pinned merge base: scoped-clean through P2.git diff --checkpassed. Windows launch paths used fixtures; real stdio ran on macOS.ClawSweeper reviewed exact head
1739b1af99be13546e7ab63ae4ebd36861d6df80: no actionable correctness/security findings and no before-merge or rank-up requests.