Skip to content

Commit adf4d49

Browse files
LinseCedclaude
andcommitted
fix(ci): keep Node 24 from deadlocking in process.exit()
Build, mutation, e2e and ratchet jobs hung for hours in `npm ci` after it had printed its summary. On the runner, the hung npm had no children and three threads left: the main thread joining the last V8Worker, which waited forever. That is Node 24's exit deadlock (nodejs/node#64274): exit joins V8's platform workers while a background Maglev/Sparkplug compile waits for the main thread. In a throwaway workflow, 6 of 80 `npm ci` runs hung on Node 24.21; with --no-maglev --no-concurrent-sparkplug, 0 of 80. NODE_OPTIONS does not take those flags, so a composite action puts a `node` shim first on PATH right after setup-node, and checks that it is active. npm starts through `#!/usr/bin/env node`, so npm and every node its scripts run go through it. The Docker builder stage gets the same shim in /usr/local/sbin (created; the Alpine image lacks it), checked the same way. Remove both once Node ships the fix. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 580482f commit adf4d49

6 files changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Node without the exit deadlock
2+
description: >
3+
Puts a `node` first on PATH that runs the real one with `--no-maglev --no-concurrent-sparkplug`.
4+
Node 24 can deadlock in process.exit() while a background Maglev/Sparkplug compile job waits for the
5+
main thread (nodejs/node#64274); measured here, about 1 in 13 `npm ci` runs never exited, and none
6+
of 80 did with these flags. NODE_OPTIONS does not accept the flags, hence the shim. `npm` starts
7+
through `#!/usr/bin/env node`, so it and every `node` its scripts call go through the shim, and
8+
forked children inherit the flags. Use right after actions/setup-node; remove once Node ships the
9+
fix.
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- name: Put the node shim first on PATH
15+
shell: bash
16+
run: |
17+
dir="$RUNNER_TEMP/node-exit-safe"
18+
mkdir -p "$dir"
19+
printf '#!/bin/sh\nexec "%s" --no-maglev --no-concurrent-sparkplug "$@"\n' "$(command -v node)" > "$dir/node"
20+
chmod +x "$dir/node"
21+
echo "$dir" >> "$GITHUB_PATH"
22+
23+
- name: Check that node runs through the shim
24+
shell: bash
25+
run: |
26+
node -e 'if (!process.execArgv.includes("--no-maglev")) { console.error("the node shim is not active"); process.exitCode = 1; }'

‎.github/workflows/ci.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ jobs:
4242
node-version: ${{ matrix.node-version }}
4343
cache: "npm"
4444

45+
- uses: ./.github/actions/node-exit-safe
46+
4547
- run: npm ci
4648
- run: npm run format:check
4749
- run: npm run lint

‎.github/workflows/e2e.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ jobs:
3131
node-version: 24
3232
cache: "npm"
3333

34+
- uses: ./.github/actions/node-exit-safe
35+
3436
- run: npm ci
3537

3638
- name: Install the browser

‎.github/workflows/quality-mutation.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
node-version: 24
2727
cache: "npm"
2828

29+
- uses: ./.github/actions/node-exit-safe
30+
2931
- run: npm ci
3032

3133
- name: Mutation gate on changed files

‎.github/workflows/quality-ratchet.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ jobs:
5050
node-version: 24
5151
cache: "npm"
5252

53+
- uses: ./.github/actions/node-exit-safe
54+
5355
- name: Install dependencies
5456
run: npm ci
5557

‎Dockerfile‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ FROM node:${NODE_VERSION} AS builder
88

99
LABEL org.opencontainers.image.source=https://github.com/SprintStartProject/sprintstart-frontend
1010

11+
# Node 24 can deadlock in process.exit() (nodejs/node#64274), which leaves `npm ci` or the build
12+
# hanging after it finished. Every `node` here, npm included, runs without the two background
13+
# compilers that trigger it; /usr/local/sbin comes before /usr/local/bin on the image's PATH, but
14+
# the Alpine image does not create it.
15+
RUN mkdir -p /usr/local/sbin \
16+
&& printf '#!/bin/sh\nexec /usr/local/bin/node --no-maglev --no-concurrent-sparkplug "$@"\n' > /usr/local/sbin/node \
17+
&& chmod +x /usr/local/sbin/node \
18+
&& node -e 'process.exitCode = process.execArgv.includes("--no-maglev") ? 0 : 1'
19+
1120
# Set the working directory inside the container
1221
WORKDIR /app
1322

0 commit comments

Comments
 (0)