#7898 · Launcher spawn failure leaves exit wait unresolved
Verdict: REPRODUCED · Root-cause confidence: high
1. TL;DR
A launcher configured with an executable override that does not exist returns success without printing anything. Both a version query and a plugin listing reproduce this on the trusted main branch, built from source. The subprocess wrapper observes the spawn error, preventing Node's default unhandled-error crash, but the shared exit waiter only observes normal exit. The failed spawn never emits that exit event, so the launcher never reaches its error reporter or sets its exit status. When no active handles remain, Node leaves with status zero despite the unfinished promise.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| A missing override yields empty output and success. | Verified | Two commands in each of two separately built checkouts return status 0 with empty stdout and stderr. |
| The exit waiter never settles after spawn failure. | Verified | A real missing-executable regression test times out after 2,000 ms in both checkouts. |
| The wrapper observes the error without propagating it to the waiter. | Verified | The trusted implementation installs an error listener to invalidate toolchain state; it does not settle the exit promise. |
| An update can leave an old override path behind. | Not exercised | This investigation uses a new, intentionally absent executable in a disposable directory; it does not run the updater. |
| The older release crashed and the reported nightly behaves identically. | Not exercised | No historical or installed release code is run. The tested source commit is current origin/main. |
3. Environment
- Public repository: get-bb/bb; trusted origin/main commit:
fab82665a3299fae8910f55d7519a3b034a03b9a. - Linux x86_64, Node v22.19.0, pnpm 9.15.0. The source package reports version 0.50.1; no claim of testing the published nightly or Node 24.
- First checkout: temporary directory A/source. Second checkout: separate temporary directory A/verify, detached at the same base commit.
- Each reproduction invocation creates a new temporary HOME and BB_DATA_DIR, then removes them. No running server, ports, provider, account, or real user data is required.
- Both clean package builds complete: 62 Turbo tasks successful. The initial full-workspace build failed because the plugin SDK runtime had not yet been generated; the repository-prescribed SDK build resolved that prerequisite.
4. Minimal reproduction
- Use a clean checkout of the trusted main commit and build the package:
git clone --single-branch --branch main https://github.com/get-bb/bb.git bb-repro cd bb-repro git checkout fab82665a3299fae8910f55d7519a3b034a03b9a pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk pnpm exec turbo run build --filter=bb-app
- Save the following independently authored harness outside the checkout as
reproduce.mjs. It executes the built packaged CLI entry with a fresh environment and a guaranteed-missing absolute override path:import { spawnSync } from "node:child_process"; import { mkdtempSync, rmSync } from "node:fs"; import { tmpdir } from "node:os"; import { join, resolve } from "node:path"; const checkout = resolve(process.argv[2]); const scratch = mkdtempSync(join(tmpdir(), "bb-cli-start-repro-")); try { for (const args of [["--version"], ["plugin", "list"]]) { const result = spawnSync( process.execPath, [join(checkout, "packages/bb-app/dist/bb.js"), ...args], { cwd: checkout, env: { HOME: scratch, PATH: process.env.PATH, BB_DATA_DIR: join(scratch, "data"), BB_CLI: join(scratch, "missing-command"), }, encoding: "utf8", timeout: 10_000, }, ); process.stdout.write(`${JSON.stringify({ args, status: result.status, signal: result.signal, stdout: result.stdout, stderr: result.stderr.replaceAll(scratch, "<temporary-directory>"), error: result.error?.message ?? null, })}\n`); } } finally { rmSync(scratch, { recursive: true, force: true }); } - Run
node /path/to/reproduce.mjs /path/to/bb-repro. Expected: each child reports a nonzero exit status and a diagnostic that identifies the missing executable. Actual, verbatim:{"args":["--version"],"status":0,"signal":null,"stdout":"","stderr":"","error":null} {"args":["plugin","list"],"status":0,"signal":null,"stdout":"","stderr":"","error":null}
Focused regression test
Save this test as packages/config/test/child-process-exit.test.ts. It uses the actual repository process wrapper, not a mock, and tests the exit waiter's failure contract.
import { spawnHostProcess } from "@bb/process-utils";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { expect, it } from "vitest";
import { waitForProcessExit } from "../src/child-process-exit.js";
it("rejects when a child process cannot start", async () => {
const directory = mkdtempSync(join(tmpdir(), "bb-process-start-failure-"));
try {
const command = join(directory, "missing-command");
const childProcess = spawnHostProcess(command, [], { stdio: "ignore" });
await expect(waitForProcessExit(childProcess)).rejects.toMatchObject({
code: "ENOENT",
path: command,
});
} finally {
rmSync(directory, { recursive: true, force: true });
}
}, 2_000);
pnpm exec turbo run test --filter=@bb/config -- test/child-process-exit.test.ts Before fix, both checkouts: FAIL test/child-process-exit.test.ts > rejects when a child process cannot start Error: Test timed out in 2000ms. Test Files 1 failed (1) Tests 1 failed (1)
Scripts, tests, and exact output are embedded here instead of committed separately, following the public reports repository's artifact policy.
5. Root cause
- runBundledCliCommand selects the executable override, starts it with inherited stdio, and awaits
waitForProcessExitbefore converting the result into an exit status. - observe installs an error listener for toolchain invalidation. As a result, ENOENT is not an unhandled EventEmitter error.
- waitForProcessExit handles an already-exited child or a future exit event only. For a failed spawn, exitCode and signalCode remain null and there is no exit event:
return new Promise<ChildProcessExitResult>((resolvePromise) => { childProcess.once("exit", (code, signal) => { resolvePromise({ code, signal }); }); }); - runLauncherEntry already prints rejected errors and sets process.exitCode to 1. It cannot act here because the awaited promise never rejects or resolves. An unfinished promise alone does not keep Node alive.
The shared exit waiter is the root-cause owner. The launcher's packaging, executable-selection rules, and fallback policy do not need to change.
6. Proposed fix
Reject the existing exit-wait promise with the original child-process error. Remove the alternative event listener when either exit or error settles the wait. Preserve the already-exited fast path and normal code/signal results. This lets the existing launcher error boundary print the native error and return failure without introducing an executable precheck race, a fallback policy, a new dependency, or a packaging change.
7. Verification
The same agent repeated the investigation in a second clean detached checkout at the exact trusted base. This is a repeat check, not an independent review. The production source was unchanged in both runs. Each checkout received its own frozen install and package build; the second regression invocation was executed rather than replayed from Turbo test cache.
git worktree add --detach /path/to/verify fab82665a3299fae8910f55d7519a3b034a03b9a cd /path/to/verify pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk pnpm exec turbo run build --filter=bb-app node /path/to/reproduce.mjs /path/to/verify pnpm exec turbo run test --filter=@bb/config -- test/child-process-exit.test.ts
Second packaged-launcher output, verbatim:
{"args":["--version"],"status":0,"signal":null,"stdout":"","stderr":"","error":null}
{"args":["plugin","list"],"status":0,"signal":null,"stdout":"","stderr":"","error":null}
The second focused test also times out after 2,000 ms. No report correction was needed. After the small helper fix, the focused test and the entire config suite pass (101 passed, one skipped); lint and typecheck also pass. The launcher suite passes (229 passed, two skipped), as does the scripts dev-supervisor suite (three passed). The rebuilt packaged launcher returns status 1 and prints ENOENT for both commands.
pnpm exec turbo run test lint typecheck --filter=@bb/config pnpm exec turbo run test --filter=bb-app pnpm exec turbo run test --filter=@bb/scripts -- test/run-dev-supervisor.test.ts pnpm exec turbo run build --filter=bb-app node /path/to/reproduce.mjs /path/to/fixed-checkout git diff --check git diff --numstat origin/main
The patch changes two files in the existing config subsystem: 38 additions and five deletions (43 changed text lines). There are no binary, dependency, generated, protocol, schema, authentication, stored-data, or packaging changes.
The optional full scripts suite has the same five failures on the fixed checkout and unchanged main: three archive tests cannot find the system zip executable, and two provider-literal ratchet tests scan SDK build scratch output. Those failures are outside the affected exit-wait contract; the focused supervisor tests pass. No system dependency was installed or unrelated production code changed.
8. Linked pull requests and related issues
No linked open pull request appears in the issue timeline or open-PR search at investigation time. Existing launch-loop scenarios concern a different event path; they are not needed to reproduce this missing-executable failure.
9. Appendix and limits
Issue content was treated only as untrusted claims. No issue-provided command, script, patch, branch, binary, or external URL was executed or fetched. The two reproduction programs were designed from trusted repository code.
Investigation commands: GitHub metadata, field and label reads; trusted-main clone/fetch and commit recording; source inspection; frozen installs; Turbo builds; the embedded launcher harness; and the embedded regression test. Source permalinks were checked against the recorded commit.
Only the two listed CLI commands were exercised. The historical release, published nightly, Node 24, update-pruning trigger, Windows, and macOS were not tested. The verified mechanism is not platform-specific, but this report's runtime evidence is Linux/Node 22.