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: build wasm filenames not as expected #310

Closed
0x65-e opened this issue Mar 26, 2023 · 11 comments
Closed

🐛 BUG: build wasm filenames not as expected #310

0x65-e opened this issue Mar 26, 2023 · 11 comments
Labels
bug Something isn't working

Comments

@0x65-e
Copy link

0x65-e commented Mar 26, 2023

Which Cloudflare product(s) does this pertain to?

Wrangler

What version of Wrangler are you using?

2.13.0

What operating system are you using?

Windows, WSL and Linux

Describe the Bug

After not running wrangler for a couple months, I tried to deploy and encountered the following error:

> npx wrangler publish --dry-run
 ⛅️ wrangler 2.13.0 
--------------------
Running custom build: cargo install -q worker-build && worker-build --release
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
    Finished release [optimized] target(s) in 0.36s
[INFO]: Installing wasm-bindgen...
[INFO]: Optimizing wasm binaries with `wasm-opt`...
[INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended
[INFO]: :-) Done in 1.65s
[INFO]: :-) Your wasm pkg is ready to publish at C:\Users\mcrai\Documents\Git Repos\mattcraig.tech\build.
X [ERROR] Could not resolve "./index_bg.wasm"

    index_bg.js:1:22:
      1 │ import * as wasm from './index_bg.wasm';~~~~~~~~~~~~~~~~~

1 error
Error: esbuild exited with status exit code: 1

X [ERROR] Command failed with exit code 1: cargo install -q worker-build && worker-build --release

Looking at the build directory, it appears that index.wasm is being generated but no index_bg.wasm, which is causing esbuild to fail.

I have not made any changes to my code or build configuration, just tried re-running workflows that worked 2 months ago with an updated version of wrangler.

@0x65-e 0x65-e added the bug Something isn't working label Mar 26, 2023
@penalosa
Copy link

Which version of Wrangler did this work with before? Could you post the contents of your wrangler.toml file?

@0x65-e
Copy link
Author

0x65-e commented Mar 27, 2023

I was previously on wrangler 2.1.9, but the issue was present on both 2.1.9 and after upgrading to 2.13.0.

It appears the underlying issue was with the worker crate. I was using the v0.0.9, but the wasm-bindgen dependency was still on v0.2.78. The latest version of worker-build, v0.0.9, is only compatible with wasm-bindgen v0.2.84 onwards, which is where the change to wasm import replacement occurs that is causing the resolution to fail. Upgrading to worker v0.0.15 updated the wasm-bindgen dependency to v0.2.84 and fixed the error.

It seems like there's a dependency link missing somewhere in this chain. worker pins the version of wasm-bindgen that it depends on, but worker-build is free to upgrade even when it's no longer compatible with the version of wasm-bindgen used. It seems like worker-build is implicitly depending on a specific version of wasm-bindgen (or a version of worker) that isn't declared as a dependency.

@jspspike
Copy link

Sorry for the delayed response on this, glad you found the root of the issue. worker and worker-build are managed in the workers-rs repo. So I will transfer this issue there

@jspspike jspspike transferred this issue from cloudflare/workers-sdk Apr 17, 2023
@jspspike jspspike removed this from workers-sdk May 8, 2023
@eli-front
Copy link

eli-front commented May 24, 2023

any updates or workarounds here?

@eli-front
Copy link

eli-front commented May 24, 2023

Here's a workaround for those looking. Change your wrangler.toml to specify a build version before 0.0.9

[build]
command = "cargo install -q worker-build --version ^0.0.8 && worker-build --release" # required

@katopz
Copy link

katopz commented Jun 19, 2023

same here

macOS 13.4
wrangler 3.1.0
wasm-pack 0.10.3

npx wrangler dev also have this issue, Thanks for workaround btw.

@mimoo
Copy link

mimoo commented Aug 2, 2023

cross posted here: cloudflare/rustwasm-worker-template#41

@dev-ardi
Copy link
Contributor

Same under linux. I feel like cloudflare workers are abandoned

@cruzluna
Copy link

Here's a workaround for those looking. Change your wrangler.toml to specify a build version before 0.0.9

[build]
command = "cargo install -q worker-build --version ^0.0.8 && worker-build --release" # required

Yep fixed my issue.

Here is my fixed wrangler.toml:

name = "name"
workers_dev = true
compatibility_date = "2022-01-20"
main = "build/worker/shim.mjs"


[[rules]]
globs = [ "**/*.wasm" ]
type = "CompiledWasm"

[build]
command = "cargo install -q worker-build --version ^0.0.8 && worker-build --release" # required

@Kakapio
Copy link
Contributor

Kakapio commented Mar 25, 2024

@kflansburg I believe you should be able to close this now? It looks to me as if this issue no longer exists with the latest version of workers.

@sanghng
Copy link

sanghng commented Oct 1, 2024

Điều này liên quan đến (các) sản phẩm Cloudflare nào?

Người chiến tranh

What version of Wrangler are you using?

2.13.0

Bạn đang sử dụng hệ điều hành nào?

Windows, WSL và Linux

Mô tả lỗi

Sau khi không chạy wrangler trong vài tháng, tôi đã cố gắng triển khai và gặp phải lỗi sau:

> npx wrangler publish --dry-run
 ⛅️ wrangler 2.13.0 
--------------------
Running custom build: cargo install -q worker-build && worker-build --release
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
    Finished release [optimized] target(s) in 0.36s
[INFO]: Installing wasm-bindgen...
[INFO]: Optimizing wasm binaries with `wasm-opt`...
[INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended
[INFO]: :-) Done in 1.65s
[INFO]: :-) Your wasm pkg is ready to publish at C:\Users\mcrai\Documents\Git Repos\mattcraig.tech\build.
X [ERROR] Could not resolve "./index_bg.wasm"

    index_bg.js:1:22:
      1 │ import * as wasm from './index_bg.wasm';~~~~~~~~~~~~~~~~~

1 error
Error: esbuild exited with status exit code: 1

X [ERROR] Command failed with exit code 1: cargo install -q worker-build && worker-build --release

Looking at the build directory, it appears that index.wasm is being generated but no index_bg.wasm, which is causing esbuild to fail.

Tôi đã không thực hiện bất kỳ thay đổi nào đối với mã hoặc cấu hình xây dựng của mình, chỉ thử chạy lại quy trình làm việc đã hoạt động cách đây 2 tháng với phiên bản cập nhật của wrangler.

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

No branches or pull requests