Commit 336ac0c
committed
fix(triage-flow): drain queued tasks during shutdown (DEREM-38)
closeActiveSandboxes snapshots both maps and clears them, then awaits
sandbox.close() / coder delete on the snapshots. While those awaits
resolve, the sandboxes whose run() they're closing reject; that
resolves the in-flight runTriageAgent calls; pLimit's microtask-driven
runNext() then dequeues the next task; that task's runTriageAgent
calls createSandbox(), repopulating the maps with workspaces that
will not be reaped before process.exit() fires.
Add a module-level shutdownRequested flag set SYNCHRONOUSLY at the top
of the signal handler (before any await, so the flip is visible to
every microtask the cleanup unblocks). runTriageAgent checks it as
its first synchronous step and returns
{ status: 'skipped', message: 'shutdown requested' } without
provisioning a workspace, so post-snapshot tasks never reach the
createSandbox call site.
Testing: typecheck, lint, format:check clean. All 55 sandcastle tests
still pass; the new path is exercised on the signal pipeline which
unit tests don't cover, but the synchronous flag check is a
straight-line guard with no other branching.1 parent 9a4b7c1 commit 336ac0c
1 file changed
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
351 | 360 | | |
352 | 361 | | |
353 | 362 | | |
| |||
360 | 369 | | |
361 | 370 | | |
362 | 371 | | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
363 | 386 | | |
364 | 387 | | |
365 | 388 | | |
| |||
586 | 609 | | |
587 | 610 | | |
588 | 611 | | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
589 | 617 | | |
590 | 618 | | |
591 | 619 | | |
| |||
0 commit comments