Skip to content

Commit 68b1124

Browse files
committed
fix(alpine): add --runInBand workaround for N-API musl crash
Workaround for upstream issue: N-API Napi::Reference destructors calling napi_delete_reference during Jest worker termination on Alpine/musl corrupt V8's JIT pages, causing SIGSEGV/SIGABRT. Changes: - Add --runInBand to Alpine CI tests (prevents parallel worker termination) - Remove explicit Reset() in ValueStorage::Remove() (reduces crash frequency) - Update P02 documentation with accurate analysis The previous "fix" was never committed - only existed in working directory. With --runInBand: 100% pass rate. Without: ~50% crash rate on Alpine Node 20. This is a known musl-specific issue with N-API reference cleanup during process termination. See: nodejs/node-addon-api#660, nodejs/node#37236
1 parent e738b8c commit 68b1124

File tree

3 files changed

+111
-349
lines changed

3 files changed

+111
-349
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,19 @@ jobs:
226226
name: test-extension-linux-${{ matrix.arch }}-musl
227227
path: ./test/fixtures/test-extension
228228
continue-on-error: true
229+
# Use --runInBand on Alpine to prevent remaining SIGSEGV crashes.
230+
# Even after removing explicit Reset() calls, Napi::FunctionReference
231+
# destructors still cause JIT corruption on Alpine x64 Node 20/24 during
232+
# parallel worker termination. Node 22/25 and ARM64 work, but for
233+
# reliability we run sequentially on all Alpine builds.
234+
# See: nodejs/node-addon-api#660, P02-investigate-flaky-native-crashes.md
229235
- run: |
230236
docker run --rm -v $(pwd):/tmp/project --entrypoint /bin/sh --platform ${{ matrix.platform }} node:${{ matrix.node-version }}-alpine -c "\
231237
apk add build-base git python3 py3-setuptools --update-cache && \
232238
cd /tmp/project && \
233239
npm ci && \
234240
npm run build:dist && \
235-
npm test"
241+
npm test -- --runInBand"
236242
237243
# Node.js compatibility tests require --experimental-sqlite flag and Node 22+
238244
# We test only on Node 24 as the experimental SQLite API may change between versions

0 commit comments

Comments
 (0)