Skip to content

CL-7221 sidecars top-level SIGTERM/SIGINT handler has no error - #605

Merged
TheGreatAxios merged 7 commits into
mainfrom
cl-7221-sidecars-top-level-sigtermsigint-handler-has-no-error
Sep 4, 2026
Merged

TheGreatAxios merged 7 commits into
mainfrom
cl-7221-sidecars-top-level-sigtermsigint-handler-has-no-error

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

CL-7221

Fixes CL-7221

orchestrator.close() and anything else that throws during shutdown
was an unhandled rejection because the signal listeners used void.
The shutdown body now catches, reports, and exits 1, and the
listeners attach a rejection handler so nothing can escape.
A drain that throws already exits 1. Pin that the failure is also
reported through reportError with operation sidecar.shutdown.
A drain that throws was logged and exited 1 without going through
the error sink. Route it through reportError with the same
sidecar.shutdown operation as other shutdown faults, then exit 1.
spyOn cannot patch the ESM local binding, so the drain-failed
test never observed reportError in CI. Inject report on
RunSidecarShutdownArgs the same way hub shutdown does.
@TheGreatAxios

Copy link
Copy Markdown
Contributor Author

Fixes CL-7221

@linear-code

linear-code Bot commented Sep 4, 2026

Copy link
Copy Markdown

CL-7221

@TheGreatAxios

Copy link
Copy Markdown
Contributor Author

Self-review

Fix is sound: the SIGTERM/SIGINT handlers now await a runSidecarShutdown that catches sync/async failures from close/drain and reports them, with attachShutdownRejectionHandler as a backstop against any residual unhandled rejection. Tests cover close-throw, drain-throw, clean-exit, and the rejection backstop.

  • CONFIRMED-FIXED: outer catch in runSidecarShutdown called reportError directly instead of the injected report parameter, bypassing the test seam the other branch uses and diverging from the function's own DI pattern. Now uses report.
  • DISMISSED: onShutdownRejection in index.ts calls reportError directly rather than taking an injectable report — this is top-level wiring (not unit-tested), consistent with how the rest of index.ts wires real dependencies, not a defect.
  • DISMISSED: double-invocation guard (shuttingDown) still only guards the async body, not the signal listeners directly — unchanged from prior behavior and out of scope for this fix (handler already returns early via the flag).

Targeted tests: bun test test/shutdown.test.ts — 7 pass, 0 fail. bun run typecheck — clean.

@TheGreatAxios
TheGreatAxios merged commit 6707764 into main Sep 4, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant