From 90b67feefe129ade89252f152af0363edc5cfc81 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Thu, 20 Aug 2026 03:36:39 -0700 Subject: [PATCH] fix: avoid unsupported recovery timestamps on web Fixes #817 --- src/io/recovery.rs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/io/recovery.rs b/src/io/recovery.rs index ad94baa01..d8a779b5e 100644 --- a/src/io/recovery.rs +++ b/src/io/recovery.rs @@ -589,6 +589,7 @@ fn diagnostic_platform() -> String { format!("{}/{}", std::env::consts::OS, std::env::consts::ARCH) } +#[cfg(not(target_arch = "wasm32"))] fn unix_seconds() -> u64 { std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) @@ -596,6 +597,11 @@ fn unix_seconds() -> u64 { .unwrap_or(0) } +#[cfg(target_arch = "wasm32")] +fn unix_seconds() -> u64 { + (js_sys::Date::now() / 1000.0) as u64 +} + fn safe_stem(value: &str) -> String { let filtered: String = value .chars() @@ -672,3 +678,41 @@ fn write_unique(directory: &Path, file_name: &str, body: &str) -> Result 0); + assert_eq!( + report.report_id, + report_id(report.source_sha256.as_deref(), report.created_unix_seconds) + ); + } +}