cloudflare/rustwasm-worker-template

Wrangler dev and publish don't work with async code

vladinator1000 opened this issue · 2 comments

Hi there, I made a reproduction repo of a case where I just couldn't publish my code with wasm because of an error unresolved import "sys".

cargo build and cargo test work just fine so I'm not sure what's causing this. I also posted this in a question in the Cloudflare community.

Hey @vladinator1000 - unfortunately, not all Rust code will work automatically with wasm-pack. there are a couple of things to understand here:

  1. when wrangler builds a type = "rust" project, it calls wasm-pack build
  2. wasm-pack build calls cargo build --target wasm32-unknown-unknown

If you run either of those above commands on their own, you'll see that you get the same error.

Unfortunately, I think one of your dependencies is relying on system level APIs that are not available in WASM-world. This is documented more fully here.

I'm going to close this since it's not something that can be solved in wrangler or this template. Hope this helps!