From 55d1c10f75e2bbb0ec7102953c96b3d8808d75d0 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Mon, 8 Sep 2025 17:10:09 +0200 Subject: [PATCH 1/6] Disable SIMD for PPC64 architecture, add UNDICI_NO_WASM_SIMD env to facilitate testing Signed-off-by: Matteo Collina --- lib/dispatcher/client-h1.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/dispatcher/client-h1.js b/lib/dispatcher/client-h1.js index 644300cdcf4..15b75724750 100644 --- a/lib/dispatcher/client-h1.js +++ b/lib/dispatcher/client-h1.js @@ -64,11 +64,18 @@ function lazyllhttp () { const llhttpWasmData = process.env.JEST_WORKER_ID ? require('../llhttp/llhttp-wasm.js') : undefined let mod - try { - mod = new WebAssembly.Module(require('../llhttp/llhttp_simd-wasm.js')) - } catch { - /* istanbul ignore next */ + // We are disabling wasm SIMD on ppc64 as it seems to be broken on Power 9 architectures. + if (process.env.UNDICI_NO_WASM_SIMD || process.arch === 'ppc64') { + try { + mod = new WebAssembly.Module(require('../llhttp/llhttp_simd-wasm.js')) + /* istanbul ignore next */ + } catch { + } + } + + /* istanbul ignore next */ + if (!mod) { // We could check if the error was caused by the simd option not // being enabled, but the occurring of this other error // * https://github.com/emscripten-core/emscripten/issues/11495 From 545b0b8b9c861fd81932cedc829ef82fb9f9f940 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Mon, 8 Sep 2025 17:22:57 +0200 Subject: [PATCH 2/6] fixup Signed-off-by: Matteo Collina --- lib/dispatcher/client-h1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dispatcher/client-h1.js b/lib/dispatcher/client-h1.js index 15b75724750..48811f4513a 100644 --- a/lib/dispatcher/client-h1.js +++ b/lib/dispatcher/client-h1.js @@ -66,7 +66,7 @@ function lazyllhttp () { let mod // We are disabling wasm SIMD on ppc64 as it seems to be broken on Power 9 architectures. - if (process.env.UNDICI_NO_WASM_SIMD || process.arch === 'ppc64') { + if (process.env.UNDICI_NO_WASM_SIMD || process.arch !== 'ppc64') { try { mod = new WebAssembly.Module(require('../llhttp/llhttp_simd-wasm.js')) /* istanbul ignore next */ From ce9f9bdd7c515fd10c41ff25fcf5fb885ef78ae0 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Mon, 8 Sep 2025 17:29:52 +0200 Subject: [PATCH 3/6] fixup Signed-off-by: Matteo Collina --- lib/dispatcher/client-h1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dispatcher/client-h1.js b/lib/dispatcher/client-h1.js index 48811f4513a..68c0da05c3b 100644 --- a/lib/dispatcher/client-h1.js +++ b/lib/dispatcher/client-h1.js @@ -66,7 +66,7 @@ function lazyllhttp () { let mod // We are disabling wasm SIMD on ppc64 as it seems to be broken on Power 9 architectures. - if (process.env.UNDICI_NO_WASM_SIMD || process.arch !== 'ppc64') { + if (!process.env.UNDICI_NO_WASM_SIMD || process.arch !== 'ppc64') { try { mod = new WebAssembly.Module(require('../llhttp/llhttp_simd-wasm.js')) /* istanbul ignore next */ From b6438b11c204fc969fd9df95e17451499b4eab2a Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Mon, 8 Sep 2025 17:30:30 +0200 Subject: [PATCH 4/6] fixup Signed-off-by: Matteo Collina --- lib/dispatcher/client-h1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dispatcher/client-h1.js b/lib/dispatcher/client-h1.js index 68c0da05c3b..cb4c814215a 100644 --- a/lib/dispatcher/client-h1.js +++ b/lib/dispatcher/client-h1.js @@ -66,7 +66,7 @@ function lazyllhttp () { let mod // We are disabling wasm SIMD on ppc64 as it seems to be broken on Power 9 architectures. - if (!process.env.UNDICI_NO_WASM_SIMD || process.arch !== 'ppc64') { + if (process.env.UNDICI_NO_WASM_SIMD !== '1' || process.arch !== 'ppc64') { try { mod = new WebAssembly.Module(require('../llhttp/llhttp_simd-wasm.js')) /* istanbul ignore next */ From ef0e7e475a67d629fa426511a56ddd2d2aa5f490 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Mon, 8 Sep 2025 08:47:39 -0700 Subject: [PATCH 5/6] Update lib/dispatcher/client-h1.js Co-authored-by: Aras Abbasi --- lib/dispatcher/client-h1.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/dispatcher/client-h1.js b/lib/dispatcher/client-h1.js index cb4c814215a..55a33f09d91 100644 --- a/lib/dispatcher/client-h1.js +++ b/lib/dispatcher/client-h1.js @@ -65,8 +65,17 @@ function lazyllhttp () { let mod - // We are disabling wasm SIMD on ppc64 as it seems to be broken on Power 9 architectures. - if (process.env.UNDICI_NO_WASM_SIMD !== '1' || process.arch !== 'ppc64') { + // We disable wasm SIMD on ppc64 as it seems to be broken on Power 9 architectures. + let useWasmSIMD = process.arch !== 'ppc64' + + // The Env Variable UNDICI_NO_WASM_SIMD allows explicitly overriding the default behavior + if (process.env.UNDICI_NO_WASM_SIMD === '1') { + useWasmSIMD = true + } else if (process.env.UNDICI_NO_WASM_SIMD === '0') { + useWasmSIMD = false + } + + if (useSIMD) { try { mod = new WebAssembly.Module(require('../llhttp/llhttp_simd-wasm.js')) /* istanbul ignore next */ From 4fcd7678e26112eafd80c7104e0f8eb591e1a2a4 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Mon, 8 Sep 2025 17:50:56 +0200 Subject: [PATCH 6/6] Apply suggestions from code review --- lib/dispatcher/client-h1.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/dispatcher/client-h1.js b/lib/dispatcher/client-h1.js index 55a33f09d91..c775cb988f4 100644 --- a/lib/dispatcher/client-h1.js +++ b/lib/dispatcher/client-h1.js @@ -67,15 +67,14 @@ function lazyllhttp () { // We disable wasm SIMD on ppc64 as it seems to be broken on Power 9 architectures. let useWasmSIMD = process.arch !== 'ppc64' - // The Env Variable UNDICI_NO_WASM_SIMD allows explicitly overriding the default behavior if (process.env.UNDICI_NO_WASM_SIMD === '1') { useWasmSIMD = true - } else if (process.env.UNDICI_NO_WASM_SIMD === '0') { + } else if (process.env.UNDICI_NO_WASM_SIMD === '0') { useWasmSIMD = false } - if (useSIMD) { + if (useWasmSIMD) { try { mod = new WebAssembly.Module(require('../llhttp/llhttp_simd-wasm.js')) /* istanbul ignore next */