Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions lib/dispatcher/client-h1.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,23 @@ 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 */

// 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
// 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
Expand Down Expand Up @@ -165,11 +165,6 @@ async function lazyllhttp () {
}

let llhttpInstance = null
/**
* @type {Promise<WebAssembly.Instance>|null}
*/
let llhttpPromise = lazyllhttp()
llhttpPromise.catch()

/**
* @type {Parser|null}
Expand Down Expand Up @@ -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) {
Expand Down
Loading