[rush] rushd: cancelling rushx-client (Ctrl+C/SIGTERM) SIGKILLs the script without a graceful signal and exits 1 with "An unknown error occurred."
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 40/100
研究方向
The issue is in libraries/rush-daemon/src/GlobalCommandExecutionContext.ts, specifically the terminateChild method. Start by examining how requestCancel is handled and how signals are forwarded. Look at SubprocessTerminator.killProcessTree and the mapping in CommandResultPolicy.ts. The fix involves adding a graceful signal phase before SIGKILL, modifying the requestCancel payload to carry the signal, and adjusting exit codes. Test with a script that traps signals to verify graceful termination.
由索引模型根據 Issue 內容生成。
描述
Summary
rushx-client forwards SIGINT/SIGTERM as requestCancel. The daemon then aborts the GlobalCommandExecutionContext, whose terminateChild immediately calls SubprocessTerminator.killProcessTree, which is process.kill(-pid, 'SIGKILL'). The script never receives SIGINT or SIGTERM. Dev servers leave lock/pid files and ports behind, and test runners skip teardown. RushXCommand then reports the killed shell as Error: An unknown error occurred., and the client exits 1 instead of 130/143.
Repro steps
Take a rushx script that traps SIGINT/SIGTERM/SIGHUP, writes a marker file, and exits 40.
| action | rushx-client (daemon) | native rushx |
|---|---|---|
| SIGINT to the client | exit 1, child SIGKILLed, trap not run, prints "Error: An unknown error occurred." | terminal Ctrl+C: trap runs, exit 130 |
| SIGTERM to the client | exit 1, trap not run, same message | exit 143 |
To its credit, the daemon kills the whole tree, so no orphans are left behind.
Expected result: Emulate a terminal Ctrl+C. Send the same signal (SIGINT/SIGTERM) to the script's process group, wait a bounded grace period (for example 2-5 s, within the client's cancellation timeout), then SIGKILL. The client exits 128 + signo and does not print a bogus "unknown error".
Actual result: The script is killed immediately with SIGKILL, the client exits 1, and the message is misleading.
Details
Root cause (main @ 60007c9a8c): libraries/rush-daemon/src/GlobalCommandExecutionContext.ts:343-355 (terminateChild) calls killProcessTree (SIGKILL) directly. CommandResultPolicy.ts:65-68 maps the result to exit code 1.
Suggested fix: add a graceful phase: process.kill(-child.pid, requestSignal ?? 'SIGINT'), then killProcessTree after a grace timeout. Carry the client's signal in requestCancel (for example an additive optional signal field). Suppress the "unknown error" message for aborted requests, and return 130/143 (related: #6060, for phased builds).
This was found during an automated performance/behavior analysis of rush-client/rushd on Linux and independently reproduced.
Standard questions
| Question | Answer |
|---|---|
@microsoft/rush globally installed version? |
built from main @ 60007c9a8c (5.179.0) |
rushVersion from rush.json? |
5.179.0 |
pnpmVersion, npmVersion, or yarnVersion from rush.json? |
[email protected] |
(if pnpm) useWorkspaces from pnpm-config.json? |
true |
| Operating system? | Linux (WSL2 Ubuntu 24.04) |
| Would you consider contributing a PR? | Yes |
Node.js version (node -v)? |
22.23.2 |
- 主要語言
- TypeScript
- 星號
- 6.5k
- 分支
- 710
- 平均合併
- 1 天 22 小時
- 30 天內合併 PR
- 37
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 沒有貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoft/rushstack 的其他 Issue
-
[api-extractor] Source map segment without a source crashes SourceMapper with "Target is a folder, not a file"可能已有人在做 @joshuaellis 於 5 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
[rush-serve-plugin] The auto-picked port never reaches the port parameter: `_value` is ignored since ts-command-line uses `#value`可能已有人在做 @b84330808 於 4 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
查看 microsoft/rushstack 的全部 Issue
相似的 Issue
-
freshness freshness:observed-only
難度 2/5 1-3 小時 新手友好度 68/100
thoroc/context-radar#282 ·
-
bug P2 rust
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
area: web
難度 2/5 1-3 小時 新手友好度 85/100
gabe-santana/arkdraw#25 ·
-
bug require-triage
難度 2/5 1-3 小時 新手友好度 72/100
expressjs/expressjs.com#2549 · 1 個 reaction ·
維護者通常 1 天內回覆
-
bug good first issue hacktoberfest
難度 2/5 1-3 小時 新手友好度 88/100
codercops/discord-bot#101 · 1 則留言 ·
維護者通常 1 天內回覆