Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[BUG] Uncaught LinkError: WebAssembly.Instance(): Import #15 "./index_bg.js" #654

Closed
1 task done
lopld opened this issue Oct 17, 2024 · 17 comments
Closed
1 task done

Comments

@lopld
Copy link

lopld commented Oct 17, 2024

Is there an existing issue for this?

  • I have searched the existing issues

What version of workers-rs are you using?

0.4.2

What version of wrangler are you using?

3.80.5

Describe the bug


Running custom build: cargo install -q worker-build && worker-build --release
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [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.17s
[INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended
[INFO]: ✨ Done in 0.57s
[INFO]: 📦 Your wasm pkg is ready to publish at C:\git\cf_workers_images\build.

The file src changed, restarting build...
Running custom build: cargo install -q worker-build && worker-build --release
[wrangler:inf] Ready on http://127.0.0.1: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.16s
[INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended
[INFO]: ✨ Done in 0.54s
[INFO]: 📦 Your wasm pkg is ready to publish at C:\git\cf_workers_images\build.

⎔ Starting local server...
✘ [ERROR] service core:user:cf_workers_images: Uncaught LinkError: WebAssembly.Instance(): Import #15 "./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.

If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose


What is index_bg.js???

Steps To Reproduce

스크린샷 2024-10-17 205927

@lopld lopld changed the title [BUG] <title> [BUG] Uncaught LinkError: WebAssembly.Instance(): Import #15 "./index_bg.js" Oct 17, 2024
@lukevalenta
Copy link

I'm also seeing this error. I can trigger it when trying to update the worker crate from 0.2.0 to anything higher.

@kflansburg
Copy link
Contributor

Are you also running in Windows?

@lukevalenta
Copy link

lukevalenta commented Oct 18, 2024

Running on macOS. (I messaged you more details in internal company chat.)

@PeterMHammond
Copy link

This just started happening for my Cloudflare Build process that has been working for weeks.
This it might be connected to the latest build of wrangler.
⛅️ wrangler 3.81.0

2024-10-18T20:21:01.013Z ✘ [ERROR] A request to the Cloudflare API (/accounts/e2ecc897eaa02efed7cb3cbc4beca1fa/workers/scripts/scripture/versions) failed. 2024-10-18T20:21:01.013Z 2024-10-18T20:21:01.013Z Uncaught LinkError: WebAssembly.Instance(): Import #30 "./index_bg.js" "__wbg_error_53abcd6a461f73d8": function import requires a callable 2024-10-18T20:21:01.013Z at null.<anonymous> (file:///opt/buildhome/repo/build/worker/shim.mjs:1:4526) 2024-10-18T20:21:01.013Z [code: 10021] 2024-10-18T20:21:01.014Z 2024-10-18T20:21:01.014Z 2024-10-18T20:21:01.014Z If you think this is a bug, please open an issue at: https://github.com/cloudflare/workers-sdk/issues/new/choose 2024-10-18T20:21:01.014Z

@PeterMHammond
Copy link

PeterMHammond commented Oct 18, 2024

I checked my commits, and confirmed this just started happening two days ago. I think I did upgrade my local Wrangler to latest, but I made no changes to the configuration of the project other than changing my own package version number. Once I noticed it was failing, I've tried multiple steps to resolve and revert back without any success. I do have similar workers, that are still building, so unsure of what's the cause. I am running on Windows, but this build process is all on Cloudflare.
image
image

@PeterMHammond
Copy link

PeterMHammond commented Oct 19, 2024

Just confirmed this other worker is now failing to build on Cloudflare as well, and the only thing I changed was the package version number to trigger a build on commit.
image
I can still build and deploy to production using: npx wrangler deploy

@dinfer
Copy link

dinfer commented Oct 19, 2024

same problem here. is workers-rs ready to be used for developers ?

@omarabid
Copy link

I suspect this is a problem on Cloudflare side. I am getting the same error message using a project with old Wrangler/worker versions.

@kflansburg
Copy link
Contributor

So far I have been unable to reproduce this. Has anyone been able to reproduce this from a fresh project (hello world template)? If you are able to reproduce, can you share the following versions: miniflare, wrangler, workerd (node_modules/@cloudflare/workerd-darwin-arm64/bin/workerd --version).

I suspect that this may be an issue with workerd or miniflare. @jasnell does this look like something we have touched recently?

@lukevalenta
Copy link

lukevalenta commented Oct 19, 2024

I think this might have to do with running on rust nightly. I just encountered the issue from the hello-world template (after running cargo generate cloudflare/workers-rs) and switching from rust nightly to stable fixed the issue for me, both in the template and in my original project.

% cargo generate cloudflare/workers-rs
⚠️    Favorite `cloudflare/workers-rs` not found in config, using it as a git repository: https://github.com/cloudflare/workers-rs.git
✔ 🤷   Which template should be expanded? · templates/hello-world
🤷   Project Name: debug
🔧   Destination: /Users/lvalenta/cf-repos/wrangler-debug/debug ...
🔧   project-name: debug ...
🔧   Generating template ...
🔧   Moving generated files into: `/Users/lvalenta/cf-repos/wrangler-debug/debug`...
🔧   Initializing a fresh Git repository
✨   Done! New project created /Users/lvalenta/cf-repos/wrangler-debug/debug
% cd debug
% npx wrangler dev
Need to install the following packages:
[email protected]
Ok to proceed? (y) y
<snip>
⎔ Starting local server...
✘ [ERROR] service core:user:debug: 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.


If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose

Then switching rust to stable, it works:

% rustc --version
rustc 1.83.0-nightly (da889684c 2024-09-20)
% rustup default stable
info: using existing install for 'stable-aarch64-apple-darwin'
info: default toolchain set to 'stable-aarch64-apple-darwin'

  stable-aarch64-apple-darwin unchanged - rustc 1.81.0 (eeb90cda1 2024-09-04)

% npx wrangler dev

 ⛅️ wrangler 3.81.0
-------------------

Running custom build: cargo install -q worker-build && worker-build --release
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│  [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...
<snip>
[INFO]: ✨   Done in 0.20s
[INFO]: 📦   Your wasm pkg is ready to publish at /path/to/debug/build.

⎔ Starting local server...
⎔ Shutting down local server...

@kflansburg
Copy link
Contributor

I think this might have to do with running on rust nightly. I just encountered the issue from the hello-world template (after running cargo generate cloudflare/workers-rs) and switching from rust nightly to stable fixed the issue for me, both in the template and in my original project.

Thanks Luke, looks like I am able to reproduce on Rust nightly.

@lopld
Copy link
Author

lopld commented Oct 19, 2024

The problem was resolved when using the stable version of Rust.
Thanks ALL.

@lopld lopld closed this as completed Oct 19, 2024
@omarabid
Copy link

It's not nightly, it's Rust version 1.82. I downgraded to 1.81 and was able to deploy.

This might be a problem with wasm-bindgen: rustwasm/wasm-bindgen#4211

@lopld lopld reopened this Oct 20, 2024
@lopld lopld closed this as completed Oct 20, 2024
@PeterMHammond
Copy link

Just in case someone wants to fix the Cloudflare build process, I changed my script to pull the specific version I'm working on locally. I assume this works by avoiding the 1.82 build.

Build command:curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.76.0 --profile minimal && export PATH="$HOME/.cargo/bin:$PATH" && rustc --version && rustup target add wasm32-unknown-unknown && cargo install -q worker-build && worker-build --release Deploy command:export PATH="$HOME/.cargo/bin:$PATH" && npx wrangler deploy Root directory:/

I hope the Cloudflare build environment will eventually handle this in a more intuitive way, perhaps with toml like GitHub or with a better prebuild image to use.
But for now this works (and adding the minimal really improved the build speed).

augustoccesar added a commit to mentimeter/linkup that referenced this issue Oct 22, 2024
This also pin the Rust toolchain to 1.81.0. We can look into removing
this pin once the issue between the wasm bindings between 1.82 and Node
18.

### References
- rustwasm/wasm-bindgen#4211
- cloudflare/workers-rs#654
@lennartkloock
Copy link

Bumping this, still an issue

@omarabid
Copy link

Bumping this, still an issue

Downgrade to 1.81 stable.

@lukevalenta
Copy link

This workaround seems to work on the current rust stable (1.82.0): webpack/webpack#15566 (comment). Add this to Cargo.toml:

[profile.release]
strip = true

The next release of wasm-bindgen should (I hope) also incorporate a more permanent fix: rustwasm/wasm-bindgen#4235.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants