Skip to content

Commit

Permalink
Fix order of WASM loading (#1204)
Browse files Browse the repository at this point in the history
* fix: loading simd should be first

* feat: inline require calls
  • Loading branch information
mcfedr authored Feb 4, 2022
1 parent 1204ed1 commit f35037a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ const {
HTTPParserError
} = require('./core/errors')
const buildConnector = require('./core/connect')
const llhttpWasmData = require('./llhttp/llhttp.wasm.js')
const llhttpSimdWasmData = require('./llhttp/llhttp_simd.wasm.js')

const {
kUrl,
kReset,
Expand Down Expand Up @@ -413,15 +410,15 @@ const EMPTY_BUF = Buffer.alloc(0)
async function lazyllhttp () {
let mod
try {
mod = await WebAssembly.compile(Buffer.from(llhttpWasmData, 'base64'))
mod = await WebAssembly.compile(Buffer.from(require('./llhttp/llhttp_simd.wasm.js'), 'base64'))
} 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(Buffer.from(llhttpSimdWasmData, 'base64'))
mod = await WebAssembly.compile(Buffer.from(require('./llhttp/llhttp.wasm.js'), 'base64'))
}

return await WebAssembly.instantiate(mod, {
Expand Down

0 comments on commit f35037a

Please sign in to comment.