Skip to content

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

Closed

Description

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)

Activity

  1. github-actions commented on Jun 5, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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