Fix wasm32 failures and panics - #128
Open
sagikazarmark wants to merge 2 commits into
Open
Conversation
Signed-off-by: Mark Sagi-Kazar <[email protected]>
sagikazarmark
marked this pull request as ready for review
September 3, 2026 23:20
Contributor
Author
|
Breaking build is unrelated to this change: Lokathor/tinyvec#225 |
Contributor
|
Hi @sagikazarmark, why you build the sdk with wasm32? We didnt really designed the sdk to be buildable with wasm... |
Contributor
Author
|
@slinkydeveloper To deploy it to Cloudflare Workers. We talked about it here: #85 (where you indicated it should work) The SDK is mostly wasm32 compatible by the way (or I should say, mostly Cloudflare Workers compatible): the time dependency can easily be replaced on wasm32, drain_input that uses tokio time wouldn't even work on Workers, because it only works with request-response mode) |
On wasm32-unknown-unknown `std::time::{Instant, SystemTime}::now()` compile
but abort at runtime with "time not implemented on this platform", and
`tokio::time::timeout` panics without a runtime. `cargo check` cannot catch
either; `just check-wasm32` (previous commit) does, and now passes.
- Import `Instant`/`SystemTime` from `web_time` on that target. It mirrors
the std API, so the call sites in `endpoint/context.rs` are unchanged and
the native build keeps using std with no new dependency.
- Skip the 60s `tokio::time::timeout` around `drain_input` on that target;
the host's request lifetime bounds the drain there instead.
- Select the `getrandom` JS backends (0.2 via shared-core -> jsonwebtoken,
0.4 via rand) in the SDK's own wasm32 target table. Every wasm32 consumer
needs them regardless of features, `web-time` already assumes a JS host,
and 0.4 still honours a consumer's `--cfg getrandom_backend`. This makes
the shim in `wasm-check` redundant, so it is removed.
Signed-off-by: Mark Sagi-Kazar <[email protected]>
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.
This PR adds a CI job for checking the SDK on wasm32.
It also fixes a couple issues that otherwise result in panic in wasm32 environments.