From c4cbcdbcd3a19b40c2c2179c527bf3ab7514bbaf Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Mon, 8 Jun 2026 17:56:29 -0700 Subject: [PATCH 1/2] Remove wasm-bindgen-futures dependency worker-build sets WASM_BINDGEN_USE_JS_SYS=1, so the #[wasm_bindgen] macro emits js_sys::futures glue directly and the worker crate no longer needs wasm-bindgen-futures. Drop the dependency and the re-export, and migrate the remaining direct users to js_sys::futures. --- Cargo.lock | 1 - Cargo.toml | 1 - examples/axum/Cargo.toml | 1 - examples/tokio-postgres/src/lib.rs | 2 +- worker/Cargo.toml | 1 - worker/src/lib.rs | 1 - worker/src/websocket.rs | 2 +- 7 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e009d0e2f..6456dc037 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4050,7 +4050,6 @@ dependencies = [ "trybuild", "url", "wasm-bindgen", - "wasm-bindgen-futures", "wasm-bindgen-test", "wasm-streams", "web-sys", diff --git a/Cargo.toml b/Cargo.toml index 5ead2a238..e8429aba7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,6 @@ proc-macro2 = "1.0.60" quote = "1.0.28" wasm-bindgen = { version = "0.2.123" } wasm-bindgen-cli-support = { version = "0.2.123" } -wasm-bindgen-futures = { version = "0.4.73" } wasm-bindgen-macro-support = { version = "0.2.123" } wasm-bindgen-shared = { version = "0.2.123" } wasm-bindgen-test = { version = "0.3.73" } diff --git a/examples/axum/Cargo.toml b/examples/axum/Cargo.toml index 37de3cc00..388fefc53 100644 --- a/examples/axum/Cargo.toml +++ b/examples/axum/Cargo.toml @@ -15,6 +15,5 @@ worker-macros = { workspace = true, features = ['http'] } axum = { version = "0.8", default-features = false, features = ['json'] } axum-macros = "0.5.0" tower-service = "0.3.3" -wasm-bindgen-futures = { workspace = true } wasm-bindgen = { workspace = true } serde = { version = "1.0", features = ["derive"] } diff --git a/examples/tokio-postgres/src/lib.rs b/examples/tokio-postgres/src/lib.rs index 803562baf..4d0bc0fb9 100644 --- a/examples/tokio-postgres/src/lib.rs +++ b/examples/tokio-postgres/src/lib.rs @@ -15,7 +15,7 @@ async fn main(_req: Request, env: Env, _ctx: Context) -> anyhow::Result = Closure; /// server.accept()?; /// /// // Spawn a future for handling the stream of events from the websocket. -/// wasm_bindgen_futures::spawn_local(async move { +/// js_sys::futures::spawn_local(async move { /// let mut event_stream = server.events().expect("could not open stream"); /// /// while let Some(event) = event_stream.next().await { From fe9d9538f2be62e252e7b976087b853597f615a7 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Mon, 8 Jun 2026 18:01:27 -0700 Subject: [PATCH 2/2] Set WASM_BINDGEN_USE_JS_SYS for all cargo invocations worker-build only sets the env var for the wasm build, but plain `cargo check`/`cargo clippy` also expand #[wasm_bindgen] on async fns (e.g. email.rs) and the generated glue references wasm_bindgen_futures. Set the opt-in in .cargo/config.toml [env] so the proc-macro emits js_sys::futures glue for host builds too. --- .cargo/config.toml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.cargo/config.toml b/.cargo/config.toml index 0e465b2de..7a4169493 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,9 @@ [target.wasm32-unknown-unknown] rustflags = ["--cfg", "getrandom_backend=\"wasm_js\""] + +# Make `#[wasm_bindgen]` emit `js_sys::futures` glue instead of +# `wasm_bindgen_futures` for every cargo invocation in this workspace +# (check, clippy, build). The proc-macro reads this at expansion time, so it +# must be present for host builds too, not just the wasm build worker-build runs. +[env] +WASM_BINDGEN_USE_JS_SYS = "1"