You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] CLI test fixtures leaking processes on Windows #42989
CLI subprocess tests leave OpenCode processes running on Windows after the suite finishes. I currently have 35 of them alive, oldest 46 hours, ~32 GB of private commit between them, still holding loopback ports and file locks on checkouts.
The cause is in packages/opencode/test/lib/cli-process.ts. It spawns children with Bun.spawn(["bun", ...]). When the suite is launched through bun x (bunx), PATH resolves "bun" to the small node_modules\.bin\bun.exe shim, which starts the real bun as a separate process and waits on it. The fixture only ever holds the shim. So kill() + await exited completes as soon as the shim dies, while the real OpenCode process keeps running with no parent.
Two helpers leak: serve() and startRun(). acp() happens to be safe because stdin EOF exits the child first, and the generic spawn() is safe because it goes through CrossSpawnSpawner, which tree-kills on Windows.
The two tests meant to catch this can't:
test/cli/serve/serve-process.test.ts asserts typeof code === "number" || code === null, which is true for every possible value.
test/cli/run/run-process.test.ts has a test named "SIGINT interrupts an active non-interactive run without leaking the process" that leaks one every run.
I have a fix ready and will open a PR against this issue.
Plugins
custom
OpenCode version
1.17.11
Steps to reproduce
On Windows, from packages/opencode, run the suite through bunx so the shim is on PATH: bun x [email protected] test test/cli/serve/serve-process.test.ts -t "kills the subprocess on scope close"
The test passes.
List bun processes: Get-CimInstance Win32_Process -Filter "Name='bun.exe'" | Select-Object ProcessId, ParentProcessId, CommandLine
There is a leftover ... src\index.ts serve --port 0 process whose parent no longer exists. It still answers HTTP on its port.
Activity
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊