[rush] rushd (Linux): rushx/global-command cleanup requires procps `ps --sid`; without it one request permanently breaks the workspace session and `daemon stop` leaves a half-closed daemon
Summary
After a rushx or global-command child exits, the daemon SIGKILLs the process group and then waits with waitForLinuxProcessGroupExitAsync. When the group still exists (killed members not yet reaped), that function shells out to ps --sid <pgid> -o stat=. If procps ps is missing, the call fails with ENOENT. That is the default in node:*-slim, distroless and many CI containers. Busybox ps (Alpine) rejects --sid, which fails the same way.
The failure is recorded as a sticky per-session resource failure, and the workspace becomes unusable:
- every later request on the session fails with the old request's error (
Failed to release resources for request "<id>": spawn ps ENOENT); - the script output of the triggering request is lost (exit 1, empty stderr);
rush-client daemon stopreportsshutdownAccepted, but the daemon never finishes closing. The listener stays bound and immediately closes connections (write EPIPE), the process does not exit, and every later command pays 16-20 s before falling back withPID ... still exists but the daemon is not ready.
Repro steps
Simulate a host without procps with a PATH that contains only node/git/sh/coreutils. Add a rushx script that leaves a backgrounded child, e.g. "bg": "(sleep 30; ...) >/dev/null 2>&1 & echo started-bg".
rushx-client build # rc 0
rushx-client bg # rc 1, no output
rushx-client build # rc 1 "Daemon rejected the request (routingFailed): Failed to release resources for request ...: spawn ps ENOENT" (forever)
rush-client daemon stop # {"state":"shutdownAccepted"} but the daemon stays alive; the socket and pid.json are left behind Expected result: Process-group liveness checks on Linux don't depend on an external ps. A cleanup-verification failure for one request is not a permanent workspace failure, and daemon stop always completes.
Actual result: A single request makes the daemon unusable until someone kills it by PID.
Details
Root cause (main @ 60007c9a8c): libraries/rush-daemon/src/LinuxProcessGroupExit.ts:48-67 execs ps. GlobalCommandExecutionContext.ts:367-372 calls it after every rushx/global child. WorkspaceRequestResources.ts:19-31 records the failure per session and retires it. The retired or closing host never completes its close.
Suggested fix: read /proc/<pid>/stat (session id and state) for group liveness, with ps only as a fallback when procfs is unavailable. A prototype of this passed the rush-daemon tests (366/366). Also: treat verification failures as request-scoped and not sticky (or retry them), and make sure shutdown completes even when a request's resource join failed.
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; simulated procps-less PATH) |
| Would you consider contributing a PR? | Yes |
Node.js version (node -v)? |
22.23.2 |
Source: microsoft/rushstack