Skip to content

Handle signal termination in @actions/exec#2328

Open
ueokande wants to merge 1 commit intoactions:mainfrom
ueokande:handle-signal-on-exec
Open

Handle signal termination in @actions/exec#2328
ueokande wants to merge 1 commit intoactions:mainfrom
ueokande:handle-signal-on-exec

Conversation

@ueokande
Copy link

@ueokande ueokande commented Mar 1, 2026

This change handles signal termination in @actions/exec. The error message in @actions/exec includes the signal when a process is terminated by a signal.

Close #2313

Child process termination via signal exit code is null and signal is set to the
terminating signal. This change handles signal termination in @actions/exec.
The error message in @actions/exec includes the signal when a process is
terminated by a signal.
Copilot AI review requested due to automatic review settings March 1, 2026 01:41
@ueokande ueokande requested a review from a team as a code owner March 1, 2026 01:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves @actions/exec’s handling of child processes that terminate via OS signals (e.g., SIGTERM), so callers receive a clearer failure reason instead of an “exit code null” error.

Changes:

  • Capture signal from Node’s child_process exit/close events and store it in ExecState.
  • Emit a dedicated error when a process ends due to a signal.
  • Add a self-terminating test script and a unit test covering signal termination.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/exec/src/toolrunner.ts Stores termination signal and produces a signal-specific failure error message.
packages/exec/tests/scripts/self-terminate.cjs New helper script that SIGTERMs itself for testing.
packages/exec/tests/exec.test.ts Adds a unit test asserting the error message includes the termination signal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +668 to 672
} else if (this.processSignal) {
error = new Error(
`The process '${this.toolPath}' failed due to signal ${this.processSignal}`
)
} else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) {
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

Signal-based termination currently throws regardless of options.ignoreReturnCode. Since ignoreReturnCode is documented as "will not fail leaving it up to the caller" (interfaces.ts), this changes behavior for callers that intentionally ignore failures. Consider honoring ignoreReturnCode for the signal case as well (or introducing/ documenting a separate option for ignoring signals).

Copilot uses AI. Check for mistakes.
)
} else if (this.processSignal) {
error = new Error(
`The process '${this.toolPath}' failed due to signal ${this.processSignal}`
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

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

The new signal-termination error message text ("failed due to signal") doesn't match the newly added test expectation ("terminated by signal"). As-is, the test will fail; consider adjusting this message to include the wording the test asserts (or update the test to match the intended message).

Suggested change
`The process '${this.toolPath}' failed due to signal ${this.processSignal}`
`The process '${this.toolPath}' terminated by signal ${this.processSignal}`

Copilot uses AI. Check for mistakes.
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.

@actions/exec: Handle receiving a signal of the child process

2 participants