cloudflare / workers-sdk

โ›…๏ธ Home to Wrangler, the CLI for Cloudflare Workersยฎ
https://developers.cloudflare.com/workers/
Apache License 2.0
2.71k stars 710 forks source link

๐Ÿ› BUG: Running rust example generated via `cargo generate cloudflare/workers-rs` fails `Uncaught LinkError: WebAssembly.Instance()` #7208

Open pmalek opened 4 days ago

pmalek commented 4 days ago

Which Cloudflare product(s) does this pertain to?

Other

What version(s) of the tool(s) are you using?

3.86.0 [Wrangler]

What version of Node are you using?

23.1.0

What operating system and version are you using?

Mac Sequoia 15.0.1

Describe the Bug

Observed behavior

Running rust example generated with cargo generate cloudflare/workers-rs fails with the following error message:

[INFO]: โฌ‡๏ธ  Installing wasm-bindgen...
[INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended
[INFO]: โœจ   Done in 0.26s
[INFO]: ๐Ÿ“ฆ   Your wasm pkg is ready to publish at /Users/USER/code_/own/cfworker1/asd/build.

The file src changed, restarting build...
Running custom build: cargo install -q worker-build && worker-build --release
[wrangler:inf] Ready on http://localhost:8787
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚  [b] open a browser, [d] open devtools, [l] turn off local mode, [c] clear console, [x] to exit  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
[INFO]: ๐ŸŽฏ  Checking for the Wasm target...
[INFO]: ๐ŸŒ€  Compiling to Wasm...
    Finished `release` profile [optimized] target(s) in 0.04s
[INFO]: โฌ‡๏ธ  Installing wasm-bindgen...
[INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended
[INFO]: โœจ   Done in 0.22s
[INFO]: ๐Ÿ“ฆ   Your wasm pkg is ready to publish at /Users/USER/code_/own/cfworker1/asd/build.

โŽ” Starting local server...
โœ˜ [ERROR] service core:user:asd: Uncaught LinkError: WebAssembly.Instance(): Import #9 "./index_bg.js" "__wbg_error_53abcd6a461f73d8": function import requires a callable

    at null.<anonymous> (shim.js:41:9)

โœ˜ [ERROR] The Workers runtime failed to start. There is likely additional logging output above.

Expected behavior

Please describe.

Steps to reproduce

Please provide the following:

A git repo we can clone and run a test suite on, or which has a README with step-by-step instructions, is even better. In this case, please use the field below to provide a link to the minimal repro.

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

o-az commented 4 days ago

downgrade to rust 1.81.0 should fix it

pmalek commented 4 days ago

I can confirm, downgrading to 1.81 works. Any particular reason this doesn't work with 1.82? Can't this be enforced somehow through dependency requirements?

o-az commented 3 days ago

I have no idea and I found out by luck ๐Ÿ˜

brentschroeter commented 1 day ago

Having the same issue, also fixed by downgrading to 1.81. Searching through GitHub issues for other projects, seems to be that Rust 1.82 enables new LLVM features by default, including WASM reference type transformations which are not yet supported by all JS tooling (for example https://github.com/rustwasm/wasm-bindgen/issues/4211).

fornwall commented 1 day ago

Issue in workers-rs: https://github.com/cloudflare/workers-rs/issues/668