monero-ts: Failed to parse URL
Error [TypeError]: Failed to parse URL from /home/xxx/Documents/GitHub/xxx-router/node_modules/monero-ts/dist/dist/monero_wallet_keys.wasm at LibraryUtils.deserializeError (/home/xxx/Documents/GitHub/xxx-router/node_modules/monero-ts/dist/src/main/ts/common/LibraryUtils.js:253:106) at LibraryUtils.invokeWorker (/home/xxx/Documents/GitHub/xxx-router/node_modules/monero-ts/dist/src/main/ts/common/LibraryUtils.js:242:26) at async MoneroWalletKeysProxy.createWallet (/home/xxx/Documents/GitHub/xxx-router/node_modules/monero-ts/dist/src/main/ts/wallet/MoneroWalletKeys.js:381:5) at async MoneroWalletKeys.createWallet (/home/xxx/Documents/GitHub/xxx-router/node_modules/monero-ts/dist/src/main/ts/wallet/MoneroWalletKeys.js:63:25) Worker error: TypeError: Failed to parse URL from /home/xxx/Documents/GitHub/xxx-router/node_modules/monero-ts/dist/dist/monero_wallet_keys.wasm at Object.fetch (node:internal/deps/undici/undici:11576:11)
import moneroTs from "monero-ts";
moneroTs.createWalletKeys({networkType: moneroTs.MoneroNetworkType.MAINNET, language: "English"}).then( async (result)=>{
const address=await result.getAddress(0,0);
const seed=await result.getSeed();
console.log(seed)
const duplicateWallet=await moneroTs.createWalletKeys({networkType:moneroTs.MoneroNetworkType.MAINNET,seed:seed});
const address2=await result.getAddress(0,0);
console.log(address)
console.log(address2)
});
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Comments: 17 (12 by maintainers)
The issue is triggered when evaluating
ifcondition in functionInstantiateAsync()inmonero_wallet_keys.js:The trigger is the availability of functioin
WebAssembly.instantiateStreaming().Prior node.js 18.1.0
WebAssembly.instantiateStreaming()was not available, henceifcondition resolves tofalse. Also for later node.js releases, flag--no-experimental-fetchcan be used, which makesWebAssembly.instantiateStreaming()unavailable, hence the fault is not triggered.So:
--no-experimental-fetch(or node.js < 18.1.0)--no-experimental-fetchWhen
WebAssembly.instantiateStreaming()is not available, the error is not triggered, but alsoisFileURI(wasmBinaryFile)is not evaluated. In caseWebAssembly.instantiateStreaming()is available,isFileURI(wasmBinaryFile)returnsfalsesincewasmBinaryFileis not prefixed withfile://.Hope this analysis helps and can lead to a solution. In the meantime use the flag
--no-experimental-fetch, which will avoid the issue.