Introduce the ability to interrupt exec() using signal (PR: #1469)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.9k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
I initially created a PR right away considering the low complexity of the change but I'm not sure if it went under the radar or not.
https://github.com/actions/toolkit/pull/1469
Describe the enhancement
When creating js/ts actions, it's currently not possible to implement a timeout mechanism within only a portion of an action.
The NodeJS child.spaws() API used by the toolkit/action does support the signal mechanism.
The goal here is to make it possible to use signal in the action.
Code Snippet
try {
core.info(`Command starting at: ${JSON.stringify(new Date())}`)
await exec.exec("sleep 10000", [], {signal: AbortSignal.timeout(5000)})
core.info(`Command completed at: ${JSON.stringify(new Date())}`)
} catch (error: any) {
if (error.name === "AbortError") {
core.info(`Timeout reached at: ${JSON.stringify(new Date())}. The command was interrupted`)
} else {
core.info(`There was an issue processing the command (${error.name}). It failed at: ${JSON.stringify(new Date())}`)
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at packages/exec/src/toolrunner.ts around line 437 and review PR #1469, which already proposes this enhancement. Confirm how the requested signal option should reach command execution, then verify that the timeout example can interrupt the command and report the resulting abort.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, node.js, typescript
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100