Skip to content

Conversation

@Dicklessgreat
Copy link

This pull request introduces compatibility with the wasm32-unknown-unknown target and replaces the standard library's time utilities with the web_time crate to improve cross-platform support. The changes also include updates to dependencies and documentation to reflect these enhancements.

Motivation

I am using dioxus and reqwest to send requests from the frontend to the backend. To enhance the client functionality, I needed to use reqwest-middleware and reqwest-retry. However, when trying this in a WASM environment, I encountered a runtime panic. Message below is from the browser’s developer tools:

panicked at library/std/src/sys/pal/wasm/../unsupported/time.rs:31:9:
time not implemented on this platform

This panic occurs because this crates use std::time::{Duration, SystemTime}, which are not supported in wasm32-unknown-unknown.

To resolve this, I replaced those with the web_time crate.

Compatibility with wasm32-unknown-unknown target:

  • .cargo/config.toml: Added rustflags configuration for the wasm32-unknown-unknown target to specify the getrandom_backend="wasm_js" feature. Please refer getrandom doc to see why this config is necessary(for checking if this crate is buildable on wasm32-unknown-unknown by cargo build --features=wasm --target=wasm32-unknown-unknown)
  • Cargo.toml: Added new dependencies (web-time, getrandom) and defined a wasm feature for compatibility with the wasm32-unknown-unknown target.

Transition to web_time crate:

Documentation updates:

  • CHANGELOG.md: Added a note about compatibility with wasm32-unknown-unknown in the changelog under the "Added" section.

@Dicklessgreat
Copy link
Author

Hi! Just checking in on this PR.
It's been a while, so I wanted to ask if there's anything I can do to help move it forward.
Happy to adjust the implementation if needed.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant