Commit 089c12d
committed
fix(build): exit watch mode cleanly on SIGINT
Both `scripts/build/main.mts` and `scripts/build/js.mts` had the same
pattern in their watch-mode SIGINT handlers: set `process.exitCode = 0`,
then `throw new Error('Watch mode interrupted')`. The throw happens
inside an `async () => {}` registered with `process.on('SIGINT', ...)`,
so it surfaces as an unhandled promise rejection — which Node exits
non-zero on, negating the `exitCode = 0` — and even when the rejection
is caught by the surrounding try/catch of `watchBuild`, the user sees
`Watch mode failed: Watch mode interrupted` instead of a clean exit.
Replaces the throw with `ctx.dispose().finally(() => process.exit(0))`,
which tears down the esbuild context then exits with status 0 whether
dispose succeeds or fails. Dev-loop Ctrl-C now closes without a stack
trace.1 parent 06d4528 commit 089c12d
2 files changed
Lines changed: 18 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
106 | | - | |
107 | | - | |
108 | | - | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | | - | |
112 | | - | |
| 112 | + | |
| 113 | + | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
260 | 261 | | |
261 | 262 | | |
262 | | - | |
263 | | - | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
264 | 267 | | |
265 | 268 | | |
266 | 269 | | |
| |||
0 commit comments