Skip to content

[BUG] CLI test fixtures leaking processes on Windows #42989

Closed as not planned
Closed as not planned

Description

@NamedIdentity

Description

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

  1. 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"
  2. The test passes.
  3. List bun processes:
    Get-CimInstance Win32_Process -Filter "Name='bun.exe'" | Select-Object ProcessId, ParentProcessId, CommandLine
  4. There is a leftover ... src\index.ts serve --port 0 process whose parent no longer exists. It still answers HTTP on its port.

Screenshot and/or share link

No response

Operating System

Windows 10

Terminal

Windows Terminal (PowerShell)

Activity

  1. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    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 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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