Skip to content

fix(windows): detach child process to prevent taskkill /F /IM node.exe from killing opencode#26127

Open
Sanjay-doppalapudi wants to merge 2 commits intoanomalyco:devfrom
Sanjay-doppalapudi:fix/windows-taskkill-node-process
Open

fix(windows): detach child process to prevent taskkill /F /IM node.exe from killing opencode#26127
Sanjay-doppalapudi wants to merge 2 commits intoanomalyco:devfrom
Sanjay-doppalapudi:fix/windows-taskkill-node-process

Conversation

@Sanjay-doppalapudi
Copy link
Copy Markdown

@Sanjay-doppalapudi Sanjay-doppalapudi commented May 7, 2026

Issue for this PR

Closes #25930

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

On Windows, when OpenCode is installed via npm, the bin/opencode launcher is a Node.js script that uses childProcess.spawnSync() to run the compiled opencode.exe binary. Because spawnSync is synchronous, the node.exe process stays alive as a blocking parent of opencode.exe for the entire session. Running taskkill /F /IM node.exe (or similar) kills the node launcher, which also brings down opencode.exe.

This fixes it by switching from spawnSync to spawn with detached: true and explicit stdio handles ([0, 1, 2]). The child process now runs in its own process group, so force-killing node.exe no longer cascades to opencode.exe.

Note: PR #25762 addresses a related but different aspect — it adds prompt/runtime guards to prevent the AI from issuing these commands. This PR fixes the underlying process architecture so that even if the commands are run (by the user manually, or any other scenario), OpenCode survives.

How did you verify your code works?

  • node --check confirms the launcher script is syntactically valid
  • bun run dev launches OpenCode correctly — TUI renders, console output works
  • Tested the patched launcher with the npm-installed version: OpenCode stays alive after running taskkill /F /IM node.exe in a separate terminal
  • Exit codes propagate correctly when OpenCode exits normally

Screenshots / recordings

N/A — no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

The following comment was made by an LLM, it may be inaccurate:

Potential Related PR Found:

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCode closes when I terminate the running node processes

1 participant