Commit 159e30a
fix(cli): remove the SIGINT handler AFTER finalize, not before (unmount-window race)
Valid review finding. The finally removed our SIGINT listener BEFORE awaiting renderer.finalize() (ink's
unmount + waitUntilExit, which takes a beat). In that window our listener was gone but ink's `signal-exit`
listener was still registered — so a second, impatient Ctrl-C during unmount would find signal-exit as the
SOLE SIGINT listener → it re-raises → exit 130 (the very failure mode a67cbd6 fixed for the first press).
Moving `process.removeListener('SIGINT', onSigint)` to AFTER finalize keeps us in the SIGINT set across the
whole unmount: a Ctrl-C during finalize hits our handler (cancelRequested already true → clean exit 1) and
signal-exit never sees itself as the sole listener. After finalize, ink has unsubscribed its own listener,
so removing ours then leaves the set clean. The abnormal-unwind `handle.cancel()` stays before finalize.
202 cli tests green (SIGINT/STALL + finalize-wiring unchanged); full gate green; format clean; Leakwatch 0.
(The exact race — a second Ctrl-C within the ~tens-of-ms unmount window — is hard to hit manually; the fix
is the same listener-set invariant a67cbd6 established, now held through teardown.)
Refs: phase-2-cli.md 2.D/2.E
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 9b4fc51 commit 159e30a
1 file changed
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
164 | 163 | | |
165 | 164 | | |
166 | 165 | | |
| |||
178 | 177 | | |
179 | 178 | | |
180 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
181 | 185 | | |
182 | 186 | | |
183 | 187 | | |
| |||
0 commit comments