Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

fix(team): exit 130 on SIGINT instead of 0 after the pane reap

Jack Rudenkob31e38329db2
diff --git a/packages/cli/src/pane/pane-registry.ts b/packages/cli/src/pane/pane-registry.ts
index acd7b603..828d2731 100644
--- a/packages/cli/src/pane/pane-registry.ts
+++ b/packages/cli/src/pane/pane-registry.ts
@@ -342,12 +342,20 @@ const SIGNALS: Array<[NodeJS.Signals, number]> = [
async function shutdown(reason: "stdin_closed" | "signal", code: number): Promise<void> {
if (shuttingDown) return;
shuttingDown = true;
+ // The reap's last waits (the pane watcher, waitForExit's timer) are unref'd. Once
+ // the cancel lets the run's main flow return, they are all that is left, and Bun
+ // exits 0 before process.exit(code) below. This interval holds the loop open.
+ const hold = setInterval(() => {}, 1_000);
try {
- await hookOpts.before?.();
- } catch {
- // a failing record writer must not keep panes alive
+ try {
+ await hookOpts.before?.();
+ } catch {
+ // a failing record writer must not keep panes alive
+ }
+ await reapAllPanes(reason);
+ } finally {
+ clearInterval(hold);
}
- await reapAllPanes(reason);
if (reason === "stdin_closed" || hookOpts.exitAfter !== false) process.exit(code);
shuttingDown = false;
}