Repository navigation
test(dev): cover repeated SIGINT/SIGTERM cleanup idempotency - #265
Merged
dDevAhmed merged 1 commit intoOct 18, 2026
Merged
Conversation
dev-orchestrator.test.ts emits each signal exactly once, so the shuttingDown guard that makes cleanup run at most once was never exercised under repetition. That guard is the whole safety story for a supervisor: without it a user hammering Ctrl-C would call child.kill() repeatedly, escalating SIGINT to SIGKILL and turning a clean shutdown into a non-deterministic exit. A RepeatingSignalSource keeps the listener registered across emits, so a second signal genuinely re-enters the handler - which process.once would not. Asserts each child is killed exactly once however many signals arrive, that a second SIGTERM and an interleaved SIGINT do not escalate, that a requested shutdown resolves rather than rejecting as 'exited unexpectedly', and that signal handlers are removed even when the signal repeats (DigiNodes#162, DigiNodes#163).
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The dev supervisor's cleanup idempotency guard had no coverage.
dev-orchestrator.test.tsemits each signal exactly once:So the
shuttingDownguard insidestopChildren— the single line that makescleanup run at most once — was never exercised under repetition.
Why this matters more than it looks
Without the guard, a user hammering Ctrl-C, or a container runtime delivering
SIGTERM alongside its own shutdown signal, would call
child.kill()repeatedly. Ona real process group that escalates SIGINT → SIGKILL, and an already-exited child
gets signalled again. The visible symptom is a non-deterministic exit code instead
of a clean shutdown — the kind of bug that only reproduces in CI under load.
A test double that actually re-enters
process.onceremoves the listener after the first signal, so emitting twiceagainst the real
processwould not re-enter the handler and would provenothing.
RepeatingSignalSourcekeeps the listener registered acrossemit, sothe second signal genuinely re-enters
stopChildren— which is the behaviour undertest.
Four cases, parameterised over both signals so #162 and #163 are covered symmetrically:
finallyThe escalation case is the sharpest: it asserts that an interleaved SIGINT after a
SIGTERM does not change what the children received, which is precisely the
guarantee the guard provides.
Issue references
Closes #161
Closes #162
Closes #163
Closes #164
What this PR actually changes
Implemented in full — #162 (SIGINT) and #163 (SIGTERM).
Not implemented here:
suite asserts
second.killedSignalsis['SIGTERM']after a child exits withcode 7, and that the original failure propagates via
rejects.toThrow('exited unexpectedly with code 7').asserts
PATHandSTELLAR_NETWORKsurvive whileSECRET_TOKENandNODE_OPTIONSare bothundefinedon the child environment.Both were verified against the code rather than assumed. This file adds only the
repetition cases, which neither existing test touches.
Not run
node_moduleswas not installed and the suite was not executed, per yourconstraint. Worth one local run to confirm — the
resolvescase depends on thechildren reporting exit after
kill(), which theFakeChilddouble drives viaqueueMicrotask.