question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module parse failed: magic header not detected (error loading wasm)

See original GitHub issue

Environment

Node v16.13.0 @callstack/repack 2.5.2 More details in reproducible demo

Description

Error in "./node_modules/bsv-wasm-bundler/bsv_wasm_bg.wasm": Module parse failed: magic header not detected
File was processed with these loaders:
 * ./node_modules/@callstack/repack/assets-loader.js
You may need an additional loader to handle the result of these loaders.
Error: magic header not detected

Is this expected behaviour? Is the header necessary if this asset (the wasm file) doesn’t need sent over the network since it will be bundled with the app? Any suggestions on how to resolve this?

Reproducible Demo

The result of the following steps can be found here https://github.com/1guzzy/AwesomeProject

experiments: {
   asyncWebAssembly: true
},
  • install wasm library npm install bsv-wasm-bundler --save
  • import library import { PrivateKey } from 'bsv-wasm-bundler' & use const random = PrivateKey.fromRandom().toHex()
  • Note: if you get this error Error in "./App.js": Module not found: Error: Can't resolve 'bsv-wasm-bundler' you have to add "main": "bsv_wasm", to node_modules/bsv-wasm-bundler/package.json

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ballercatcommented, Jun 2, 2022

Don’t bother with non async Wasm loading. Pretty sure V8 at least has a cap on the size of the binary it’ll load synchronously and it’s small enough to not matter for anything useful since it forces the runtime to freeze the main thread while loading the binary.

1reaction
ballercatcommented, Jun 2, 2022

Okay gotcha, I’m out of my depth with ReactNative as I’ve never used it in the past.

Anytime you get a header error it’s a sure sign that the runtime is not getting a correct binary format. So I’d look into why that is. Loaders can be weird and may change the contents of the original file to make it “work” within a webpack app. What you’re looking for is for the raw binary Buffer containing the contents of the original file being passed to the JS runtime.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WASM react module parse failed: magic header not detected
I was getting the magic number error when fetching the wasm from its javascript wrapper (e.g. a.out.js) because of a routing problem with...
Read more >
Wasm React Module Parse Failed: Magic Header ... - ADocLib
magic header not detected File was processed with these loaders:. I have issue using webassembly wasm file in React with Typescript. const path...
Read more >
wasm-loader | Yarn - Package Manager
A simple .wasm binary file loader for Webpack. Import your wasm modules directly into your bundle as Constructors which return WebAssembly.Instance .
Read more >
[Solved]-React - Module parse failed-Reactjs
[Solved]-React - Module parse failed-Reactjs · npm i --save-dev babel-loader babel-preset-react babel-preset-es2015 · add to webpack.config.js configs for babel- ...
Read more >
Check-in [67f13ff3ae] - SQLite
Use a wasm runtime error, because a JS error might be seen as a foreign ... if (!response['ok']) { throw "failed to load...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found