CompileError: WebAssembly.instantiate(): Wasm code generation disallowed by embedder
Hey folks,
I'm trying to run a wasm file compiled by emscripten on CF workers. It's working fine locally, but when I try it in production I get:
This page seems to indicate that
WebAssembly.instantiate
should work, am I missing something?
https://developers.cloudflare.com/workers/runtime-apis/webassembly/WebAssembly (Wasm) · Cloudflare Workers docs
Execute code written in a language other than JavaScript or write an entire Cloudflare Worker in Rust.
6 Replies
The module can't be inlined as a buffer, it needs to be uploaded as a separate .wasm file
Thanks for taking the time to answer. It is; the emscripten glue is fetching it
The error happens on
instantiate
, but the fetch
code before works without error:
Fetch as in from a URL? That's basically the same thing as loading it as a Buffer.
Yeah fetched from a URL
How should I proceed?
Does it need to be like bundled in?
My understanding was that .wasm code is typically fetched over the network, and I was thinking this would help with worker bundle size given the wasm file is almost 1mb itself
It needs to be bundled
Sorry I'm slightly confused, above when you said "it needs to be uploaded as a separate .wasm file", that's not contrary to the idea of bundling it?
I assume something like this https://vitejs.dev/guide/features#webassembly which will include it in the bundle. I also realized that paid is now 10mb. I'll give that a go, thanks for the help.