fix(pubsub): drop tokio/time from the wasm build (#4023)#4027
Open
0xMars42 wants to merge 1 commit into
Open
Conversation
DaniPopes
approved these changes
Jun 7, 2026
63c9c1e to
1cc45cd
Compare
Author
|
Updated. The first version was incomplete: alloy-pubsub also imported Verified by reproducing the For reference, the |
alloy-provider with the `ws` feature pulled `tokio` with the `time` feature on wasm32-unknown-unknown, which panics at runtime when a tokio Runtime is built there, crashing wasm apps that use alloy-provider/ws (alloy-rs#4023). Two paths pulled `tokio/time` into the wasm build: - tokio-stream's default features enable `time`; disable them at the workspace level (alloy-pubsub only uses tokio-stream's `sync`). This is the path in the issue's cargo tree. - alloy-pubsub's `handle.rs` imported `tokio::time::Duration`; switch to `std::time::Duration` (same type; the `tokio::time` path needs the `time` feature, `Duration` does not). alloy-pubsub already uses `wasmtimer::tokio::sleep` on wasm and `tokio::time::sleep` off-wasm (where `tokio/time` is provided by alloy-transport), so this only removes the feature from the wasm build. Closes alloy-rs#4023.
1cc45cd to
b5bfbc4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
alloy-providerwith thewsfeature pullstokiowith thetimefeature onwasm32-unknown-unknown.tokio/timepanics at runtime when a tokioRuntimeis built there, so awasm app using
alloy-provider/wscrashes (#4023).Root cause
Two paths enable
tokio/timein the wasm build:tokio-stream's default features includetime(time = ["tokio/time"]), andalloy-pubsubpulls
tokio-stream. This is the path shown in the issue'scargo tree.alloy-pubsub'shandle.rsimportstokio::time::Duration. Thetokio::timemodule pathrequires the
timefeature, even thoughDurationitself is juststd::time::Duration.Fix
default-features = falseon the workspacetokio-stream(alloy-pubsub only uses itssyncfeature).
std::time::Durationinstead oftokio::time::Durationinalloy-pubsub.alloy-pubsubalready useswasmtimer::tokio::sleepon wasm andtokio::time::sleepoff-wasm, andgets
tokio/timeon native viaalloy-transport, so this only drops the feature from the wasmtarget.
Verification
tokio/timeis no longer pulled into the wasm build:cargo tree -e features -i tokio -p alloy-provider --features ws --target wasm32-unknown-unknowngoes from 3 matches to 0 with this change.
alloy-providerwithwscompiles forwasm32-unknown-unknown(the issue's scenario), and therepo's
wasm-unknownCI job (cargo hack build --features ws --target wasm32-unknown-unknown,same excludes) builds clean locally.
alloy-pubsubis unaffected (tokio/timecomes fromalloy-transport).Closes #4023.