Problem
When a run is cancelled via the API, the status is set to cancelled in the DB, but the currently executing step.run callback continues to run until completion. Durably only checks the cancellation status between steps, so long-running steps cannot be interrupted.
Example
A crawl job fetches 129 PRs inside a single step.run. Even after cancellation, all 129 PR fetches continue because the step callback is not aware of the cancellation.
await step.run('fetch:owner/repo', async () => {
// This runs for 10+ minutes fetching 129 PRs one by one
// No way to check if the run was cancelled
await provider.fetch(orgId, repository, options)
})
Proposal
Pass an AbortSignal to the step.run callback so long-running operations can cooperatively check for cancellation:
await step.run('fetch:owner/repo', async (signal) => {
await provider.fetch(orgId, repository, { ...options, signal })
})
When a run is cancelled, durably would abort the signal, and the callback can check signal.aborted or pass it to fetch calls / loops:
for (const pr of prs) {
if (signal.aborted) break
await fetchDetails(pr)
}
This keeps cancellation cooperative (no forced termination) while giving step authors the ability to respond to cancellation promptly.
Problem
When a run is cancelled via the API, the status is set to
cancelledin the DB, but the currently executingstep.runcallback continues to run until completion. Durably only checks the cancellation status between steps, so long-running steps cannot be interrupted.Example
A crawl job fetches 129 PRs inside a single
step.run. Even after cancellation, all 129 PR fetches continue because the step callback is not aware of the cancellation.Proposal
Pass an
AbortSignalto thestep.runcallback so long-running operations can cooperatively check for cancellation:When a run is cancelled, durably would abort the signal, and the callback can check
signal.abortedor pass it to fetch calls / loops:This keeps cancellation cooperative (no forced termination) while giving step authors the ability to respond to cancellation promptly.