From 6960c158fbc702278d229c75abad48caa78e2fd7 Mon Sep 17 00:00:00 2001 From: Levi Zim Date: Sat, 21 Mar 2026 15:17:51 +0800 Subject: [PATCH 1/3] fix: disable wasm highlighter on riscv64 riscv64 with sv39 has limited virtual memory space, where creating too many (>=20) wasm memory instances fails. See https://github.com/nodejs/node/pull/60591 for more details. This PR fixes the following error encountered during `make test-only` on riscv64: [07:02:55.797] ERROR: WebAssembly.instantiate(): Out of memory: Cannot allocate Wasm memory for new instance RangeError: WebAssembly.instantiate(): Out of memory: Cannot allocate Wasm memory for new instancemake[1]: *** [Makefile:392: test/addons/.docbuildstamp] Error 1 make: *** [Makefile:352: test-only] Error 2 Signed-off-by: Levi Zim --- src/utils/highlighter.mjs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/highlighter.mjs b/src/utils/highlighter.mjs index dee6acad..65071c03 100644 --- a/src/utils/highlighter.mjs +++ b/src/utils/highlighter.mjs @@ -39,7 +39,11 @@ function isCodeBlock(node) { export const highlighter = await createHighlighter({ // s390x machines throw memory issues on WASM builds // https://github.com/nodejs/node/blob/c9acf345922bd758fbb3f16ee6256aa165260219/test/common/sea.js#L55 - wasm: process.arch !== 's390x', + // + // riscv64 with sv39 has limited virtual memory space, where creating + // too many (>20) wasm memory instances fails. + // https://github.com/nodejs/node/pull/60591 + wasm: !['riscv64', 's390x'].includes(process.arch), }); /** From de9922a4dd50d517217e698d8938c8e6f2a0e402 Mon Sep 17 00:00:00 2001 From: Levi Zim Date: Sat, 21 Mar 2026 19:49:19 +0800 Subject: [PATCH 2/3] fix: enable wasm highlighter for s390x The bug for s390x has been fixed. --- src/utils/highlighter.mjs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/utils/highlighter.mjs b/src/utils/highlighter.mjs index 65071c03..985b9c3c 100644 --- a/src/utils/highlighter.mjs +++ b/src/utils/highlighter.mjs @@ -37,13 +37,10 @@ function isCodeBlock(node) { } export const highlighter = await createHighlighter({ - // s390x machines throw memory issues on WASM builds - // https://github.com/nodejs/node/blob/c9acf345922bd758fbb3f16ee6256aa165260219/test/common/sea.js#L55 - // // riscv64 with sv39 has limited virtual memory space, where creating // too many (>20) wasm memory instances fails. // https://github.com/nodejs/node/pull/60591 - wasm: !['riscv64', 's390x'].includes(process.arch), + wasm: process.arch !== 'riscv64', }); /** From 2ce69e30edf0103f4504f7a1f1851af3ce08aa55 Mon Sep 17 00:00:00 2001 From: kxxt Date: Sat, 21 Mar 2026 22:43:29 +0800 Subject: [PATCH 3/3] fix: limit threads to 1 on riscv64 And warn user if they set it to a larger value. --- src/utils/configuration/index.mjs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/utils/configuration/index.mjs b/src/utils/configuration/index.mjs index fd3d210d..acedda6c 100644 --- a/src/utils/configuration/index.mjs +++ b/src/utils/configuration/index.mjs @@ -5,6 +5,7 @@ import { coerce } from 'semver'; import { CHANGELOG_URL, populate } from './templates.mjs'; import { allGenerators } from '../../generators/index.mjs'; +import logger from '../../logger/index.mjs'; import { parseChangelog, parseIndex } from '../../parsers/markdown.mjs'; import { enforceArray } from '../array.mjs'; import { leftHandAssign } from '../generators.mjs'; @@ -33,7 +34,11 @@ export const getDefaultConfig = lazy(() => }), }, - threads: cpus().length, + // The number of wasm memory instances is severely limited on + // riscv64 with sv39. Running multiple generators that use wasm in + // parallel could cause failures to allocate new wasm instance. + // See also https://github.com/nodejs/node/pull/60591 + threads: process.arch === 'riscv64' ? 1 : cpus().length, chunkSize: 10, }) ) @@ -121,6 +126,14 @@ export const createRunConfiguration = async options => { merged.threads = Math.max(merged.threads, 1); merged.chunkSize = Math.max(merged.chunkSize, 1); + if (process.arch === 'riscv64' && merged.threads > 1) { + logger.warn( + `Using ${merged.threads} threads might cause failures when` + + 'allocating wasm memory due to insufficient virtual address space' + + 'on riscv64 with sv39. Please consider using only a single thread.' + ); + } + // Transform global config if it wasn't already done await transformConfig(merged.global);