feat: Add WASM support#1100
Conversation
|
This PR has been automatically closed. The referenced issue does not show a discussion between you and a maintainer. To avoid wasted effort on both sides, please discuss your proposed approach in the issue first and wait for a maintainer to respond before opening a PR. Please review our contributing guidelines for more details. |
|
Amazing work, thank you! I would like to recommend using
|
|
@szokeasaurusrex Would you mind re-opening the PR? It was merely auto-closed because the link to #226 is missing in the PR description. |
|
Hi @LeoniePhiline, thanks for following up. As I suggested in my comment on #226, we currently do not have capacity to work on WASM support ourselves, or to properly review PRs that aim to add it. While WASM support is still something we want for the Rust SDK, we do not have a concrete timeline right now. Because of the above, I would prefer to keep this PR closed. Reopening it would create the expectation that the team can review it in the near future, which unfortunately is not the case. I would have suggested closing the PR myself had the bot not already done so. Thanks again to @darrell-roberts for putting this together; it may still be useful as input when we get to WASM support. To keep the discussion in one place, please use #226 for further discussion about WASM support. I am going to lock this PR conversation for that reason. |
|
Also @LeoniePhiline, just so you are aware, we have deactivated that PR-closing bot after receiving feedback that it was closing PRs too aggressively, so it should no longer be an issue |
Description
This adds WASM support to the
sentry-*crates.New crate:
sentry-timesentry-time/) exposingnow_system_time() -> SystemTime.SystemTime::now().target_arch = "wasm32"): buildsSystemTimefromchrono::Utc::now()(sinceSystemTime::now()panics onwasm32-unknown-unknown).Cargo.toml.Replace
SystemTime::now()call sitesAll call sites that produced a current timestamp now go through
sentry_time::now_system_time(or are#[serde(default = "sentry_time::now_system_time")]):sentry-types/src/auth.rs,protocol/session.rs,protocol/v7.rs(Breadcrumb, Event, Span, Transaction defaults +Span::finish/Transaction::finish).sentry-core/src/lib.rs(re-exportssentry_timeas#[doc(hidden)] pub use),logger.rs(4 macro arms now use$crate::sentry_time::now_system_time()),performance.rs,session.rs.sentry-log/src/converters.rs.Instant→chronofor elapsed time (WASM-incompatibleInstant)sentry-core/src/batcher.rs:Instant/std::time::Durationswapped forchrono::{DateTime<Utc>, Duration}.FLUSH_INTERVALnowDuration::seconds(5);last_flush.elapsed()becomesUtc::now() - last_flush;.checked_sub(...).to_std()bridges back tostd::time::Durationforcvar.wait_timeout.sentry-core/src/session.rs:Session.started: Instant→DateTime<Utc>; flusher loop converted analogously,chrono::Duration::from_std(FLUSH_INTERVAL).Platform-gated deps
sentry-contexts/Cargo.toml:hostnamemoved undercfg(not(target_arch = "wasm32"));unamegated oncfg(all(not(windows), not(target_arch = "wasm32"))).sentry-contexts/src/utils.rs:server_name()returnsNoneon WASM;os_context()on WASM returnsOsContext { name: Some("WASM"), ..default() }.Cargo updates
sentry-core,sentry-types,sentry-logaddsentry-timepath dep.sentry-coreandsentry-typesaddchrono = "0.4.44"direct dep.sentry-typesflipstimecrate todefault-features = false(drops std-only timer features for WASM).sentry-timepackage;chrononow pullsjs-sys+wasm-bindgen.Notes / things worth flagging
pub use sentry_timeinsentry-coreis#[doc(hidden)]— fine, but it's part of the public macro surface (needed by thelogger.rsmacros). Removing it later would be breaking.os_context()text is hard-coded"WASM"; left a// TODO: What other options are available?forserver_name().wasm32test target wired up here).Issues
Reminders
feat:,fix:,ref:,meta:, etc.)