Skip to content

bash.ts: detached=true leaves zombie processes when command times out #30868

Description

@LifetimeVip

Description

File: packages/core/src/tool/bash.ts:143-148

const command = ChildProcess.make(parameters.command, [], {
  cwd: target.canonical,
  shell,
  stdin: "ignore",
  detached: process.platform !== "win32",
  forceKillAfter: Duration.seconds(3),
})

detached: true on non-Windows puts the command in its own process group. When Effect.timeoutOrElse fires (L157), the Effect's scope cleanup only kills the direct child — grandchild processes survive. Meanwhile bash.ts:162-170 treats timeout as a SUCCESS (timedOut: true) and returns it to the AI, so the AI may retry while the original process is still running.

Repro: AI runs a long command (e.g., npm install). It times out. AI gets "Command exceeded timeout" (not an error). AI retries. Original npm is still writing to node_modules. Race condition → corruption.

Fix: Remove detached or add explicit process-group cleanup on timeout.

OpenCode version

v1.16.0 (commit 3cf1cef)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions