trustwallet / wallet-core

Cross-platform, cross-blockchain wallet library.
https://developer.trustwallet.com/wallet-core
Apache License 2.0
2.76k stars 1.56k forks source link

wallet-core.wasm doesn't load in Worker #3811

Open ArturLevchuk opened 4 months ago

ArturLevchuk commented 4 months ago

Describe the bug I'm trying to use Workers with wallet-core lib and get this type of error: Failed to execute 'fetch' on 'WorkerGlobalScope': Failed to parse URL from /node_modules/@trustwallet/wallet-core/dist/lib/wallet-core.wasm

To Reproduce Steps to reproduce the behavior:

module.exports = function (self) {
self.onmessage = async function (event) {
    const { HDWallet} = await initWasm();
    const wallet = HDWallet.create(128, passphrase || "");

    const result = JSON.stringify({
      mnemonic:  wallet.mnemonic(),
      passphrase: passphrase,
    });
    self.postMessage(result);
  };
};

Screenshots image

Additional context I'm using these plugins: image

satoshiotomakan commented 4 months ago

Hi @ArturLevchuk, could you please clarify if it can't load wallet-core.wasm in a Worker only? Does it work in a main thread (just like without workers)?

ArturLevchuk commented 4 months ago

Hi @ArturLevchuk, could you please clarify if it can't load wallet-core.wasm in a Worker only? Does it work in a main thread (just like without workers)?

In the main thread it works good. But in Worker it doesn't

satoshiotomakan commented 4 months ago

Hi @ArturLevchuk, sorry for the delay, I couldn't find a solution quickly, so postpone it I'll give an update the next week