Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

πŸ› BUG: wasm code generation disallowed by embedder [code: 10021] #1366

Closed
UnsungHero97 opened this issue Jun 29, 2022 · 1 comment
Closed
Labels
bug Something that isn't working

Comments

@UnsungHero97
Copy link

UnsungHero97 commented Jun 29, 2022

What version of Wrangler are you using?

2.0.15

What operating system are you using?

macos catalina 10.15.7

Describe the Bug

Running npx wrangler publish throws the following error:

✘ [ERROR] A request to the Cloudflare API (/accounts/.../workers/scripts/api) failed.

  Uncaught Error: CompileError: WebAssembly.Module(): Wasm code generation disallowed by embedder
    at line 0
   [code: 10021]

I'm not using wasm things myself but perhaps some dependency is? I'm not sure where to look. Also, it's hard to debug the build with publish --dry-run --outdir=build because there is no line 0. I've tried this with node v18.0.0 as well as node v18.4.0. I've also tried both true and false for node_compat; same thing.

Searching for wasm things in the project returns this:

$ find . -name "*wasm*"
./node_modules/xxhash-wasm
./node_modules/xxhash-wasm/esm/xxhash-wasm.js.map
./node_modules/xxhash-wasm/esm/xxhash-wasm.js
./node_modules/xxhash-wasm/umd/xxhash-wasm.js.map
./node_modules/xxhash-wasm/umd/xxhash-wasm.js
./node_modules/xxhash-wasm/cjs/xxhash-wasm.cjs
./node_modules/xxhash-wasm/cjs/xxhash-wasm.cjs.map
./node_modules/blake3-wasm
./node_modules/blake3-wasm/dist/wasm
./node_modules/blake3-wasm/dist/wasm/nodejs/blake3_js_bg.wasm
./node_modules/blake3-wasm/dist/wasm/web/blake3_js_bg.wasm
./node_modules/blake3-wasm/dist/wasm/browser/blake3_js_bg.wasm
./node_modules/blake3-wasm/dist/browser/wasm.d.ts
./node_modules/blake3-wasm/dist/browser/wasm.js.map
./node_modules/blake3-wasm/dist/browser/wasm.js
./node_modules/blake3-wasm/dist/node/wasm.d.ts
./node_modules/blake3-wasm/dist/node/wasm.js.map
./node_modules/blake3-wasm/dist/node/wasm.js
./node_modules/blake3-wasm/esm/browser/wasm.d.ts
./node_modules/blake3-wasm/esm/browser/wasm.js.map
./node_modules/blake3-wasm/esm/browser/wasm.js
./node_modules/blake3-wasm/esm/node/wasm.d.ts
./node_modules/blake3-wasm/esm/node/wasm.js.map
./node_modules/blake3-wasm/esm/node/wasm.js
./node_modules/undici/lib/llhttp/llhttp.wasm.js
./node_modules/undici/lib/llhttp/llhttp_simd.wasm.js
./node_modules/undici/lib/llhttp/llhttp.wasm
./node_modules/undici/lib/llhttp/llhttp_simd.wasm
./node_modules/html-rewriter-wasm
./node_modules/html-rewriter-wasm/dist/html_rewriter_bg.wasm

Update:

After digging a little deeper, I see the following in the build:

var A = new WebAssembly.Instance(new WebAssembly.Module(Uint8Array.from(atob("AGFzbQEAAAABCgJgAABgAn9/AXwDAwIAAQUDAQACBwkCAW0CAAFjAAEIAQAKlQECSQEDfwNAIAEhAEEAIQIDQCAAQQF2IABBAXFBoIbi7X5scyEAIAJBAWoiAkEIRw0ACyABQQJ0IAA2AgAgAUEBaiIBQYACRw0ACwtJAQF/IAFBf3MhAUGAgAQhAkGAgAQgAGohAANAIAFB/wFxIAItAABzQQJ0KAIAIAFBCHZzIQEgAkEBaiICIABJDQALIAFBf3O4Cw"), (n2) => n2.charCodeAt(0))));

This is coming from a dependency, client-zip:

https://github.com/Touffy/client-zip/blob/master/src/crc32.ts

@UnsungHero97 UnsungHero97 added the bug Something that isn't working label Jun 29, 2022
@petebacondarwin petebacondarwin moved this to Untriaged in workers-sdk Jun 29, 2022
@threepointone
Copy link
Contributor

Cloudflare Workers deals with wasm differently than other runtimes. Specifically, you can't initialise an instance from a string like above, it has to be a separate modules that's imported. Here's an example https://github.com/cloudflare/wrangler2/blob/dee034b5b8628fec9afe3d1bf6aa392f269f6cd4/fixtures/wasm-app/worker/module/export_wasm.js#L2-L10

That library client-zip appears to have been written for node.js, which has different assumptions and apis.

A work around would be to swap out that library for one that does work on workers, or rewrite the module. This seems like a discussion for our community resources like discord, so I'm going to close this issue, but happy to discuss if you need more clarification.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something that isn't working
Projects
None yet
Development

No branches or pull requests

2 participants