Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix order of WASM loading #1204

Merged
merged 2 commits into from
Feb 4, 2022
Merged

Fix order of WASM loading #1204

merged 2 commits into from
Feb 4, 2022

Conversation

mcfedr
Copy link
Contributor

@mcfedr mcfedr commented Feb 4, 2022

Recent changes to how the wasm is loaded in #1183 have accidentally changed the order of simd/other builds.

You can see in the diff, originally the

  try {
-    mod = await WebAssembly.compile(await readFile(resolve(__dirname, './llhttp/llhttp_simd.wasm')))
+    mod = await WebAssembly.compile(Buffer.from(llhttpWasmData, 'base64'))
  } catch (e) {
...
-    mod = await WebAssembly.compile(await readFile(resolve(__dirname, './llhttp/llhttp.wasm')))
+    mod = await WebAssembly.compile(Buffer.from(llhttpSimdWasmData, 'base64'))
  }

This makes sense because the simd build should throw when it isnt supported, and the catch loads the basic version.

Currently no one will be using the simd version.

This PR changes the order back, so that simd is loaded first, and on error we can the basic version.

I've also inlined the require call to the base64 JS module, this way most of the time the text of the basic version doesnt need to be loaded.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ronag ronag merged commit f35037a into nodejs:main Feb 4, 2022
KhafraDev pushed a commit to KhafraDev/undici that referenced this pull request Jun 23, 2022
* fix: loading simd should be first

* feat: inline require calls
metcoder95 pushed a commit to metcoder95/undici that referenced this pull request Dec 26, 2022
* fix: loading simd should be first

* feat: inline require calls
crysmags pushed a commit to crysmags/undici that referenced this pull request Feb 27, 2024
* fix: loading simd should be first

* feat: inline require calls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants