Repository navigation
Description
Bug: exec tool returns spawn UNKNOWN after gateway restart
What happened
After a gateway restart (config.patch triggers restart), the exec tool occasionally fails with spawn UNKNOWN error. This breaks all shell command execution until the pool recovers or another restart happens.
Environment
- OpenClaw: 2026.5.28 (e932160)
- OS: Windows 10.0.26200 (x64)
- Node: v24.16.0
Reproduction
- Run a config.patch that triggers a gateway restart (e.g., model fallback change)
- Immediately after restart, invoke the exec tool
- Observe spawn UNKNOWN error instead of command execution
This also manifests as gh CLI commands failing with the same error, confirming it is a general exec tool issue, not specific to one command.
Root cause analysis
The gateway restart process drains active tasks and attempts in-process restart on Windows (detached respawn is disabled on win32 unless schtasks is available). The child_process pool that backs the exec tool appears to not be fully rebuilt after the in-process restart cycle completes. This leaves exec in a broken state.
Related: the drain race condition during restart (markRestartAbortedMainSessions exists in source) may leave the process pool in an inconsistent state.
Impact
- Severity: P0 — all exec-dependent features broken (code execution, shell scripts, CLI tools, Housekeeping cron jobs)
- Frequency: After each gateway restart on Windows
- Affected: Windows primarily (in-process restart path); may affect other platforms with similar restart paths
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 2, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 21, 2026, 5:13 AM ET / 09:13 UTC.
Summary
Keep open: current main and the latest release do not prove the Windows post-restart
spawn UNKNOWNsymptom is fixed, while source contradicts the reported child-process-pool root cause and no live Windows current-main reproduction is available.Reproducibility: no. high-confidence current-main reproduction yet. Source shows a non-
EBADFspawn error such asUNKNOWNwould propagate, but this review did not establish that Gateway restart triggers it on Windows current main.Ways to help us reproduce this
Next step
Manual review should collect live Windows current-main evidence before repair because the source contradicts the stated pool root cause and no canonical fix owns this exact symptom.
Review details
Best possible solution:
Capture live Windows current-main proof for a restart-required
config.patchfollowed by immediate exec, then fix the proven layer with focusedUNKNOWNspawn hardening or restart lifecycle repair plus regression coverage.Do we have a high-confidence way to reproduce the issue?
No high-confidence current-main reproduction yet. Source shows a non-
EBADFspawn error such asUNKNOWNwould propagate, but this review did not establish that Gateway restart triggers it on Windows current main.Is this the best way to solve the issue?
Unclear. Rebuilding a child_process pool is not the best fix because current exec creates supervisor runs per spawn; the right repair depends on whether live evidence points to transient Windows spawn failure, handle exhaustion, or restart lifecycle state.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
config.patchrestart followed by immediate exec has been captured, so the trigger remains unconfirmed.spawn UNKNOWNsymptom.Codex review notes: model internal, reasoning high; reviewed against e9b694ef9cd8.
Label changes
Label changes:
issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.clawsweeper:needs-live-repro: Current issue advisory state selects this label.clawsweeper:needs-info: Current issue advisory state no longer selects this label.issue-rating: 🦪 silver shellfish: Current issue advisory state no longer selects this label.Label justifications:
P1: The report describes exec-dependent agent and maintenance workflows becoming unusable after Gateway restart on Windows.impact:crash-loop: The reported failure is a process-level availability loss where shell execution stays broken until recovery or another restart.Evidence reviewed
What I checked:
supervisor.spawnfor the PTY or child invocation, so the central path does not expose a reusable child_process pool to rebuild after restart. (src/agents/bash-tools.exec-runtime.ts:612, e9b694ef9cd8)spawn, andreconcileOrphansremains a no-op documenting in-memory ownership only; this supports the existing source-review concern that restart lifecycle may matter, but not a pool rebuild. (src/process/supervisor/supervisor.ts:123, e9b694ef9cd8)EBADFby default and throws non-retry spawn errors, so a NodeUNKNOWNspawn error would still surface if Windows emits it. (src/process/spawn-utils.ts:25, e9b694ef9cd8)src/cli/gateway-cli/run-loop.ts:795, e9b694ef9cd8)v2026.6.9has the same exec supervisor call shape, no-op orphan reconciliation, andEBADF-only spawn retry default, so this exact symptom is not proven fixed in the shipped release either. (src/process/spawn-utils.ts:25, c645ec4555c0)Likely related people:
src/process/spawn-utils.ts,src/process/supervisor/supervisor.ts,src/process/supervisor/adapters/child.ts)src/process/spawn-utils.ts,src/cli/gateway-cli/run-loop.ts,src/process/command-queue.ts)src/process/supervisor/supervisor.ts,src/process/supervisor/adapters/child.ts,src/agents/bash-tools.exec-runtime.ts)src/infra/process-respawn.ts,src/infra/windows-task-restart.ts,src/process/supervisor/adapters/child.ts)src/infra/process-respawn.ts,src/infra/process-respawn.test.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.yetval commentedon Jun 6, 2026
Thanks for the detailed write up and root cause analysis on this one.
I traced the full restart and exec path on current main and the described mechanism does not seem to hold, since there is no child_process pool to rebuild and the process supervisor is stateless between spawns and builds a fresh child on every call. The in process SIGUSR1 restart resets the command lanes and the task registry but never changes the working directory or the environment, so it should not leave exec in a broken state, and spawn UNKNOWN on Windows is an OS level error from child_process.spawn that is usually environmental such as handle exhaustion. Given that the stated cause looks contradicted by the source and there is no live Windows reproduction this may not be reproducible as written, so a redacted log or a recording would really help if anyone can capture it again. Separately, hardening the Windows spawn path with a retry for transient UNKNOWN errors seems reasonable and might be worth its own issue.
openclaw-barnacle commentedon Jul 6, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.
openclaw-barnacle commentedon Jul 14, 2026
Closing due to inactivity.
If this is still an issue, please retry on the latest OpenClaw release and share updated details.
If you are absolutely sure it still happens on the latest release, open a new issue with fresh steps to reproduce.