Repository navigation
Description
What happens
The packaged macOS app can fail to launch: the window never appears and the main process sits in spawnSync. ps shows /bin/zsh -ilc printf "%s" "$PATH" children of the app, alive long after the 2s timeout. This happens with an ordinary heavy shell setup (oh-my-zsh, completions, pyenv) on a loaded machine.
Why
apps/desktop/src/desktop-shell-path.ts runs the login shell with spawnSync(..., { timeout: 2_000 }). When it times out, Node sends the default kill signal, SIGTERM. An interactive shell (-i) ignores SIGTERM, so the child survives, and spawnSync keeps waiting on it. The app's main process stays blocked indefinitely.
A second, smaller issue: 2s is short enough that a healthy but heavy shell setup times out, and the app then runs with launchd's bare PATH, so provider CLIs installed under nvm or ~/.local/bin aren't found.
Fix (patch below, against desktop-v0.42.1)
killSignal: "SIGKILL": a timed-out probe always ends.stdio: ["ignore", "pipe", "pipe"]: the shell has no stdin that any startup file could wait on.- Timeout 2s → 10s.
Tests
The new test "kills a shell that ignores SIGTERM instead of blocking the app" uses trap '' TERM; sleep 30 with a 500ms timeout. It blocks for 30s without the fix and returns in under a second with it. desktop-shell-path.test.ts passes 9/9, and apps/desktop typechecks.
Patch
Subject: [PATCH] patch: launch never hangs on the login-shell PATH probe
Interactive zsh ignores SIGTERM, spawnSync's default kill signal, so a probe
that outlived its 2s timeout was never killed and the desktop main process
stayed blocked: bb would not launch. Kill with SIGKILL, give the shell no
stdin, and allow 10s so a heavy but healthy shell setup is not cut off.
---
apps/desktop/src/desktop-shell-path.ts | 13 ++++++--
apps/desktop/test/desktop-shell-path.test.ts | 31 ++++++++++++++++++--
2 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/apps/desktop/src/desktop-shell-path.ts b/apps/desktop/src/desktop-shell-path.ts
index 8546a928..5f42ffc1 100644
--- a/apps/desktop/src/desktop-shell-path.ts
+++ b/apps/desktop/src/desktop-shell-path.ts
@@ -2,7 +2,9 @@ import { spawnSync } from "node:child_process";
const MACOS_LOGIN_SHELL = "/bin/zsh";
const SHELL_PATH_COMMAND = 'printf "%s" "$PATH"';
-const SHELL_PATH_TIMEOUT_MS = 2_000;
+// A real oh-my-zsh + completion setup takes seconds under load; at 2s it timed
+// out and the app launched with launchd's bare PATH (no codex, claude, node).
+const SHELL_PATH_TIMEOUT_MS = 10_000;
export interface DesktopShellPathLogger {
warn(message: string): void;
@@ -54,12 +56,19 @@ interface ShellPathUpdatedResult {
path: string;
}
-function defaultSpawnLoginShellPath(
+export function defaultSpawnLoginShellPath(
args: SpawnLoginShellPathArgs,
): ShellPathSpawnResult {
const result = spawnSync(args.command, args.args, {
encoding: "utf8",
timeout: args.timeoutMs,
+ // An INTERACTIVE shell (-i) ignores SIGTERM, which is spawnSync's default
+ // kill signal, so a timed-out probe was never killed and the app's main
+ // process stayed blocked in spawnSync: bb would not launch (2026-09-11).
+ killSignal: "SIGKILL",
+ // Nothing may wait on input. An inherited or open stdin lets any startup
+ // file that reads it (prompts, update checks) hang the probe.
+ stdio: ["ignore", "pipe", "pipe"],
});
return {
diff --git a/apps/desktop/test/desktop-shell-path.test.ts b/apps/desktop/test/desktop-shell-path.test.ts
index b53ef250..15983485 100644
--- a/apps/desktop/test/desktop-shell-path.test.ts
+++ b/apps/desktop/test/desktop-shell-path.test.ts
@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import {
+ defaultSpawnLoginShellPath,
ensurePackagedUserShellPath,
type DesktopShellPathLogger,
type ShellPathSpawnResult,
@@ -92,7 +93,7 @@ describe("desktop shell PATH loading", () => {
{
args: ["-ilc", 'printf "%s" "$PATH"'],
command: "/bin/zsh",
- timeoutMs: 2_000,
+ timeoutMs: 10_000,
},
]);
});
@@ -183,7 +184,7 @@ describe("desktop shell PATH loading", () => {
{
args: ["-ilc", 'printf "%s" "$PATH"'],
command: "/usr/bin/fish",
- timeoutMs: 2_000,
+ timeoutMs: 10_000,
},
]);
});
@@ -222,4 +223,30 @@ describe("desktop shell PATH loading", () => {
});
expect(env.PATH).toBe("C:\\Windows\\System32");
});
+
+ it("kills a shell that ignores SIGTERM instead of blocking the app", () => {
+ // Interactive zsh ignores SIGTERM; with the default kill signal the probe
+ // never ended and the desktop main process hung at launch.
+ const started = Date.now();
+ const result = defaultSpawnLoginShellPath({
+ command: "/bin/sh",
+ args: ["-c", "trap '' TERM; sleep 30"],
+ timeoutMs: 500,
+ });
+ expect(Date.now() - started).toBeLessThan(5_000);
+ expect(result.signal).toBe("SIGKILL");
+ });
+
+ it("gives the shell no stdin to wait on", () => {
+ // `cat` returns at once on /dev/null; with an open stdin it would block
+ // until the timeout.
+ const started = Date.now();
+ const result = defaultSpawnLoginShellPath({
+ command: "/bin/sh",
+ args: ["-c", "cat; printf done"],
+ timeoutMs: 5_000,
+ });
+ expect(result.stdout).toBe("done");
+ expect(Date.now() - started).toBeLessThan(2_000);
+ });
});
--
2.51.0
Activity
bb-slop-cop commentedon Sep 11, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotBug · High priority · Low effort —
desktop,confirmed-repro.REPRODUCED · High confidence. The synchronous interactive-shell probe survives its default timeout signal, blocking startup until the shell exits. A controlled six-second startup exceeded the two-second timeout in two clean trusted checkouts.
Reproduction and root-cause report · Fix PR #3491
The regression failed before the fix and passed afterward (~2 seconds). Desktop tests and typecheck passed: 324 tests passed, one skipped. The fix changes 37 lines across two files. Packaged GUI launch and heavy-configuration CLI discovery were not exercised.
Bound desktop shell probe termination (get-bb#3491)