-
Notifications
You must be signed in to change notification settings - Fork 710
[rush-daemon] Terminate running operations when a daemon client cancels #6065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Sean Larkin (TheLarkInn)
merged 6 commits into
main
from
thelarkinn-fix-rushd-ctrl-c-cancellation
Sep 25, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
af2f5c5
[rush-daemon] Terminate running operations when a daemon client cancels
TheLarkInn 7a256e3
[rush-daemon] Address review: kill exited-shell process groups, honor…
TheLarkInn 2c2fd15
Merge remote-tracking branch 'origin/main' into thelarkinn-fix-rushd-…
TheLarkInn 3c2d378
Merge remote-tracking branch 'origin/main' into thelarkinn-fix-rushd-…
TheLarkInn 8fd86f9
[rush-daemon] Tolerate gated scripts being terminated by a hard abort…
TheLarkInn 1ffc41a
Merge remote-tracking branch 'origin/main' into thelarkinn-fix-rushd-…
TheLarkInn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
| // See LICENSE in the project root for license information. | ||
|
|
||
| import * as os from 'node:os'; | ||
|
|
||
| import type { DaemonClientOutcome } from '@rushstack/rush-client-core'; | ||
|
|
||
| /** Signals that cancel a daemon-routed command. */ | ||
| export const CANCELLATION_SIGNALS: ReadonlyArray<NodeJS.Signals> = ['SIGINT', 'SIGTERM', 'SIGHUP']; | ||
|
|
||
| const SIGNAL_EXIT_CODE_BASE: number = 128; | ||
|
|
||
| /** | ||
| * Returns the conventional shell exit code for a process terminated by `signal` (128 + signal number), | ||
| * e.g. 130 for SIGINT and 143 for SIGTERM. | ||
| */ | ||
| export function getSignalExitCode(signal: NodeJS.Signals): number { | ||
| return SIGNAL_EXIT_CODE_BASE + (os.constants.signals[signal] ?? os.constants.signals.SIGINT); | ||
| } | ||
|
|
||
| /** Formats the notice printed when a daemon-routed command is cancelled. */ | ||
| export function formatCancellationMessage(commandName: string): string { | ||
| return `rush-client: ${commandName} cancelled.\n`; | ||
| } | ||
|
|
||
| /** | ||
| * Returns whether a daemon outcome represents a cancelled command. A result is cancelled when the daemon reports it | ||
| * as aborted, even if an operation failure determines its semantic outcome. A completed (non-aborted) result wins | ||
| * over a late signal, and a rejection is never reported as a cancellation. | ||
| */ | ||
| export function isCancelledOutcome(outcome: DaemonClientOutcome, signalled: boolean): boolean { | ||
| switch (outcome.kind) { | ||
| case 'result': | ||
| return outcome.result.aborted; | ||
| case 'rejected': | ||
| return false; | ||
| default: | ||
| return signalled; | ||
| } | ||
| } |
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
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
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
11 changes: 11 additions & 0 deletions
11
common/changes/@microsoft/rush/rushd-cancel-hard-abort_2026-09-23.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "@microsoft/rush", | ||
| "comment": "Add an opt-in hard abort for operation graphs (`abortCurrentIterationAsync({ terminateRunning: true })`) that terminates running shell operation process trees and reports them as Aborted; daemon engine graphs enable it.", | ||
| "type": "none" | ||
| } | ||
| ], | ||
| "packageName": "@microsoft/rush", | ||
| "email": "selarkin@microsoft.com" | ||
| } |
11 changes: 11 additions & 0 deletions
11
common/changes/@rushstack/rush-cli-client/rushd-cancel-hard-abort_2026-09-23.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "@rushstack/rush-cli-client", | ||
| "comment": "Exit with 128+signal (130/143/129) and print a cancellation notice when a daemon-routed command is cancelled; handle SIGHUP like SIGTERM.", | ||
| "type": "patch" | ||
| } | ||
| ], | ||
| "packageName": "@rushstack/rush-cli-client", | ||
| "email": "selarkin@microsoft.com" | ||
| } |
11 changes: 11 additions & 0 deletions
11
common/changes/@rushstack/rush-daemon/rushd-cancel-hard-abort_2026-09-23.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "@rushstack/rush-daemon", | ||
| "comment": "Terminate running operations when the last live client cancels a phased request, and answer a cancelling client immediately when other clients still need the shared work.", | ||
| "type": "patch" | ||
| } | ||
| ], | ||
| "packageName": "@rushstack/rush-daemon", | ||
| "email": "selarkin@microsoft.com" | ||
| } |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.