fix: signint-terminated process exits with code 130#134
Merged
felipefreitag merged 2 commits intomainfrom Mar 19, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
cubic analysis
1 issue found across 5 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/lib/cli-exit.test.ts">
<violation number="1" location="tests/lib/cli-exit.test.ts:14">
P2: The test cleanup only removes `SIGINT` listeners, but `setupCliExitHandler()` also adds an `uncaughtException` listener. This leaks process listeners across tests.</violation>
</file>
Linked issue analysis
Linked issue: ENG-4687: A SIGINT-terminated process should exit with code 130
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | SIGINT-terminated process should exit with code 130 (POSIX) | Default handler exits with CANCEL_EXIT_CODE (130) |
| ✅ | Global SIGINT handler must be replaceable so commands can run cleanup before exiting (setSigintHandler) | Added setSigintHandler managing currentSigintHandler and listeners |
| ✅ | listen commands (webhooks and emails receiving) should use setSigintHandler() and exit with cancel code instead of 0 | Both listen files use setSigintHandler and process.exit(getCancelExitCode()) |
| ✅ | Clear terminal line before "Cancelled." when stderr is a TTY | defaultSigintHandler writes '\r\x1B[2K' when stderr.isTTY |
| ✅ | Add expectExitCode test helper and preserve expectExit1 alias | expectExitCode added and expectExit1 now calls it |
| ✅ | Add unit tests for cli-exit: getCancelExitCode, default handler exit, TTY clearing, setSigintHandler replacement | New tests cover getCancelExitCode, default handler, TTY behavior, and replacement |
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
vcapretz
approved these changes
Mar 19, 2026
Make the global SIGINT handler replaceable so listen commands can run cleanup before exiting. Both webhooks listen and emails receiving listen now use setSigintHandler() and exit 130 instead of 0. - Add setSigintHandler() to cli-exit.ts for command-specific handlers - Clear terminal line before "Cancelled." when stderr is TTY - Add expectExitCode() test helper and cli-exit unit tests
d1289f6 to
b2e5c89
Compare
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.
Make the global SIGINT handler replaceable so listen commands can run cleanup before exiting. Both webhooks listen and emails receiving listen now use setSigintHandler() and exit 130 instead of 0.