Skip to content

fix: signint-terminated process exits with code 130#134

Merged
felipefreitag merged 2 commits intomainfrom
worktree-fix-eng-4687-sigint-exit-code-130
Mar 19, 2026
Merged

fix: signint-terminated process exits with code 130#134
felipefreitag merged 2 commits intomainfrom
worktree-fix-eng-4687-sigint-exit-code-130

Conversation

@felipefreitag
Copy link
Contributor

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

@felipefreitag felipefreitag requested a review from vcapretz March 19, 2026 18:21
@felipefreitag felipefreitag changed the title fix: SIGINT-terminated process exits with code 130 fix: signint-terminated process exits with code 130 Mar 19, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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
@felipefreitag felipefreitag force-pushed the worktree-fix-eng-4687-sigint-exit-code-130 branch from d1289f6 to b2e5c89 Compare March 19, 2026 19:16
@felipefreitag felipefreitag merged commit 4c5cbc6 into main Mar 19, 2026
6 checks passed
@felipefreitag felipefreitag deleted the worktree-fix-eng-4687-sigint-exit-code-130 branch March 19, 2026 19:18
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.

2 participants