I cannot initialize my WebAssembly built from Rust. It told me failed to fetch when I call init()
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 30/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- rust, typescript, wasm
Research direction
Start by reproducing the failure from index.tsx, focusing on the await init call inside onRpcRequest and the referenced pkg/hello_wasm.js and hello_wasm_bg.wasm paths. Check snap.manifest.json alongside the Rust-to-Wasm setup guide; done means the WebAssembly module initializes successfully when the localhost:8000 request is sent.
Written by the indexing model from the issue text.
Description
Hi, I am trying to add the WebAssembly I built from Rust by this guide into my Snap. I added the pkg folder into /packages/snap
In my index.tsx, I added import init, { greet, get_hello_world_string } from '../pkg/hello_wasm.js';.
Then I was trying to add await init('../pkg/hello_wasm_bg.wasm'); into onRpcRequest. I did not work and I was given error "failed to fetch" when I click send message in the webpage of localhost:8000.
I also tried await fetch('./hello_wasm_bg.wasm'); and await fetch('../pkg/hello_wasm_bg.wasm'); They were all giving the same error failed to fetch.
I already added "endowment:network-access": {}, "endowment:webassembly": {} into my snap.manifest.json
Can any tell me how can I add my WebAssembly correctly into my Snap?
- Dominant language
- TypeScript
- Stars
- 853
- Forks
- 662
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 8
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MetaMask/snaps
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
snaps-refined-backlog
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
snaps-refined-backlog
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
snaps-refined-backlog
Difficulty 4/5 3-5 days Newbie friendliness 15/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·