diff --git a/lib/dispatcher/client-h1.js b/lib/dispatcher/client-h1.js index ddae9831289..92fe69ac540 100644 --- a/lib/dispatcher/client-h1.js +++ b/lib/dispatcher/client-h1.js @@ -60,12 +60,12 @@ const removeAllListeners = util.removeAllListeners let extractBody -async function lazyllhttp () { +function lazyllhttp () { const llhttpWasmData = process.env.JEST_WORKER_ID ? require('../llhttp/llhttp-wasm.js') : undefined let mod try { - mod = await WebAssembly.compile(require('../llhttp/llhttp_simd-wasm.js')) + mod = new WebAssembly.Module(require('../llhttp/llhttp_simd-wasm.js')) } catch (e) { /* istanbul ignore next */ @@ -73,10 +73,10 @@ async function lazyllhttp () { // being enabled, but the occurring of this other error // * https://github.com/emscripten-core/emscripten/issues/11495 // got me to remove that check to avoid breaking Node 12. - mod = await WebAssembly.compile(llhttpWasmData || require('../llhttp/llhttp-wasm.js')) + mod = new WebAssembly.Module(llhttpWasmData || require('../llhttp/llhttp-wasm.js')) } - return await WebAssembly.instantiate(mod, { + return new WebAssembly.Instance(mod, { env: { /** * @param {number} p @@ -165,11 +165,6 @@ async function lazyllhttp () { } let llhttpInstance = null -/** - * @type {Promise|null} - */ -let llhttpPromise = lazyllhttp() -llhttpPromise.catch() /** * @type {Parser|null} @@ -769,11 +764,7 @@ async function connectH1 (client, socket) { client[kSocket] = socket if (!llhttpInstance) { - const noop = () => {} - socket.on('error', noop) - llhttpInstance = await llhttpPromise - llhttpPromise = null - socket.off('error', noop) + llhttpInstance = lazyllhttp() } if (socket.errored) {