Repository navigation
fix(workers): stop cloud workers when computer cleanup hangs - #175189
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d530ceaba2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await withTimeout( | ||
| options.closeEnvironmentComputers(environmentId, ownerEpoch), | ||
| COMPUTER_CLEANUP_TIMEOUT_MS, | ||
| "Worker computer cleanup", | ||
| ); |
There was a problem hiding this comment.
Release timed-out computer owners before returning
When a computer driver truly never settles, withTimeout only stops awaiting closeEnvironmentComputers; it neither cancels that promise nor removes its owner. The unresolved owner remains in computer-service.ts's attachedOwners, so a later Gateway shutdown calls computers.close(), rejoins the same permanently pending PreparedWorkerComputer.close() promise, and blocks service.stop() before tunnel teardown. Thus Stop can now return, but the next restart or update still hangs for the exact failure mode this change handles; the timeout path must also detach/fence the abandoned computer owner or make shutdown bound that retained promise.
AGENTS.md reference: AGENTS.md:L83-L83
Useful? React with 👍 / 👎.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs changes before merge. What this changesThis PR bounds computer cleanup to one minute per teardown phase and lets dedicated cloud-machine destruction continue after cleanup fails. Example: Stop a dedicated cloud worker whose computer driver never finishes closing.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR open: it addresses a real teardown failure, but its timeout leaves a retained computer owner that can still block subsequent Gateway shutdown. Priority: P1 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe Gateway worker lifecycle joins computer and transport cleanup before destroying a provider lease; the computer service separately retains prepared owners for environment cleanup and Gateway shutdown. flowchart TD
A[Stop or idle reclaim] --> B[Worker lifecycle]
B --> C[Transport cleanup]
C --> D[Computer owner]
C --> E[Provider destruction]
D --> F[Retained close promise]
G[Gateway shutdown] --> F
Technical reviewBest possible solution: Complete timeout recovery in the computer owner so confirmed dedicated-machine destruction cannot leave Gateway shutdown waiting forever. Do we have a high-confidence way to reproduce the issue? Source establishes the failure path: retain an attached computer with a never-settling close, finish dedicated-machine destruction through the new timeout, then call service.stop; no runtime reproduction was executed during this review. Is this the best way to solve the issue? Bounding optional cleanup while preserving dedicated-host checks is useful, but the recovery must also settle the computer owner's shutdown responsibility. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1062d2b530eb. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +31, Tests +108, Docs +2. Total +141 across 4 files. Added test files: 0. View PR surface stats
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 Reviewed October 17, 2026, 2:09 AM ET / 06:09 UTC. |
A wedged computer (desktop) driver blocked every teardown of its cloud worker, including idle reclaim, Stop and force, because transport teardown awaited driver cleanup without a bound. Each computer cleanup phase now gets 60 s. On a provider-owned dedicated machine (sharedHost false with a node device) a failure or timeout logs a warning with recovery guidance and provider teardown continues; shared or unknown hosts still require cleanup acknowledgement and fail after the bound. Fixes openclaw#166196
Fixes #166196
What Problem This Solves
Fixes cloud-worker Stop, idle reclaim, and forced destruction remaining blocked indefinitely when optional computer-driver cleanup never settles.
User Impact
Dedicated cloud machines can reach provider teardown after a wedged desktop cleanup. Each cleanup phase has a one-minute deadline, and failures log guidance to check the provider lease and retry Stop if it remains running. Shared or unknown hosts still require their worker's stop acknowledgement.
Why This Change Was Made
Environment teardown joined computer cleanup without a deadline before calling the provider. Bound the entire cleanup callback, including pending preparation, in-flight actions, and native close replies. The budget allows two normal 30-second node-command windows. Only dedicated-machine teardown tolerates computer cleanup failure; other transport errors continue to propagate. A stop reason alone never permits this bypass: the transport reads the stored environment and also requires
nodeDeviceId !== null && sharedHost === false.The simplification pass retained the existing transport owner and timeout helper: 31 net production lines and 108 test/fixture lines were added.
Evidence
15a39da700dab0966debe2c033b4020e44fba1df: the new normal/forced teardown regressions failed because provider destruction was never invoked; the 12 existing cases passed. Wall time: 343.75s.d530ceaba28: the two new shared/unknown-host boundary cases failed because cleanup resolved after the timeout instead of rejecting; the other 14 tests passed. Wall time: 244.39s.pnpm test src/gateway/worker-environments/provider-node-teardown.test.ts --maxWorkers=1: 16 passed, wall time 272.24s, including compiled-worker preparation and cleanup. Shared (true) and unknown (null) hosts reject a never-settling driver cleanup after 60 seconds even when directly supplied a provider teardown reason, and do not log that teardown will continue. Dedicated normal/forced destruction and the existing host-isolation cases remain covered. Fake timers; no real sleeps.pnpm exec oxfmt --checkon all four changed files: passed.node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/gateway/worker-environments/environment-access.ts src/gateway/worker-environments/provider-node-teardown.test.ts: passed (follow-up changed files; the unchanged fixture retained its prior passing check).git diff --check: passed.pnpm run tsgo:corewas attempted but could not start TypeScript checking: the declaration wrapper rejects dependencies symlinked from another checkout (0.91s). Tests and lint used prepared dependencies with an identical lockfile. Full core typecheck and broad proof remain for PR CI; CI timing is pending.