Commit 39b25bd
authored
fix(init): terminate verification process trees (#1258)
## Summary
Post-init verification currently kills only the direct shell process and
waits for its close event. Package scripts that launch concurrently,
framework dev servers, or file watchers leave descendants holding stdout
and stderr open, so sentry init can remain stuck on Verifying setup even
though the remote workflow already succeeded.
This starts the verification command in a dedicated POSIX process group
and terminates the complete tree during cleanup and signal forwarding.
POSIX cleanup is bounded: it sends SIGTERM, escalates to SIGKILL after
five seconds, and destroys the local pipe ends so inherited descriptors
cannot keep the CLI alive. Windows force-terminates the disposable
verification tree with a bounded `taskkill /T /F` invocation and falls
back to the direct child if that fails.
The verification path now also handles asynchronous child-process spawn
errors. A missing or invalid dev command produces a best-effort
verification warning instead of crashing a successful init run.
## Safety properties
- Shell pipelines, concurrently tasks, framework servers, and watchers
are terminated as one process tree.
- POSIX descendants that ignore SIGTERM are force-killed after the grace
period.
- Cleanup never waits indefinitely for ChildProcess close.
- SIGINT and SIGTERM are forwarded to the POSIX process group; Windows
force-terminates the disposable tree before the signal is re-emitted by
the CLI.
- Windows `taskkill` calls have their own one-second timeout, debug
diagnostics, and direct-child fallback.
- Spawn failures remain non-fatal because verification runs after setup
has succeeded.
## Test plan
- `pnpm exec vitest run test/lib/init/verify-setup.test.ts
test/lib/init/verify-setup-windows.mocked.test.ts
test/lib/dev-script.test.ts test/lib/init/wizard-runner.test.ts` — 75
tests pass, including forced Windows tree cleanup, timeout/status
diagnostics, and direct-child fallback.
- `TZ=UTC pnpm exec vitest run test/lib test/commands test/types
test/script --coverage --exclude test/lib/completions.property.test.ts`
— 400 files, 8,459 tests pass, 14 skipped.
- `pnpm exec tsc --noEmit` — passes.
- `pnpm run lint` — 919 files pass.
- `SENTRY_CLIENT_ID=test-build-only pnpm tsx script/build.ts --single` —
darwin-arm64 build passes.
- `git diff --check` — passes.
The unmodified broad test command reaches 8,470 passing tests and 8
unrelated failures. Six time-range assertions assume UTC while the local
timezone is Europe/Madrid. Two Bash completion simulations fail on the
system Bash 3.2 because the generated script uses extglob syntax without
enabling extglob; neither area is touched by this PR.1 parent 6ae8f55 commit 39b25bd
3 files changed
Lines changed: 524 additions & 30 deletions
File tree
- src/lib/init
- test/lib/init
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
29 | 41 | | |
30 | 42 | | |
31 | 43 | | |
| |||
187 | 199 | | |
188 | 200 | | |
189 | 201 | | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
194 | 210 | | |
| 211 | + | |
195 | 212 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
210 | 229 | | |
211 | | - | |
212 | | - | |
213 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
214 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
215 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
216 | 271 | | |
217 | | - | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
218 | 320 | | |
219 | 321 | | |
220 | 322 | | |
| |||
272 | 374 | | |
273 | 375 | | |
274 | 376 | | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
275 | 380 | | |
276 | 381 | | |
277 | 382 | | |
| |||
286 | 391 | | |
287 | 392 | | |
288 | 393 | | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
| 394 | + | |
| 395 | + | |
293 | 396 | | |
294 | 397 | | |
295 | 398 | | |
| |||
312 | 415 | | |
313 | 416 | | |
314 | 417 | | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
315 | 425 | | |
316 | 426 | | |
317 | 427 | | |
318 | 428 | | |
319 | 429 | | |
320 | 430 | | |
| 431 | + | |
321 | 432 | | |
322 | 433 | | |
323 | 434 | | |
| |||
330 | 441 | | |
331 | 442 | | |
332 | 443 | | |
333 | | - | |
334 | | - | |
| 444 | + | |
| 445 | + | |
335 | 446 | | |
336 | 447 | | |
337 | | - | |
| 448 | + | |
338 | 449 | | |
339 | 450 | | |
340 | 451 | | |
| |||
369 | 480 | | |
370 | 481 | | |
371 | 482 | | |
| 483 | + | |
372 | 484 | | |
373 | 485 | | |
374 | 486 | | |
| |||
401 | 513 | | |
402 | 514 | | |
403 | 515 | | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
404 | 522 | | |
405 | 523 | | |
406 | 524 | | |
| |||
0 commit comments