Conversation
wasm32-unknown-unknown has no std clock: SystemTime::now() panics with "time not implemented on this platform". Two sites read it directly and both sit in the commit path, so the first write from an embedded build panicked: - WriteTxn::commit builds CommitHistoryMeta, whose timestamp is the history entry's unix_seconds. - The age-based retention policy computes its pruning threshold from the clock on every commit. Route both through crate::clock::unix_seconds(): js_sys on the OPFS build, std elsewhere (wasm32-wasip1 included), and 0 for a wasm build without the JS bindings — the history ordering tolerates that instead of panicking. The btree allocation-cost test keeps its loop on every target but runs the wall-clock bound only where a clock exists. wasm-smoke/ is a separate crate because the pagedb dev-dependencies (tokio rt-multi-thread, tempfile) do not compile for wasm32, and Cargo builds every dev-dependency for a crate's test targets. Its two tests fail with the panic above before this change and pass after; the new `wasm-tests` CI job runs them under node, so the compile-only wasm job is no longer the last line of defence.
This branch has not been deployed
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.
Problem
wasm32-unknown-unknownhas no std clock. Two sites read it directly, and both sit in the commit path, so the first write from an embedded build panicked:WriteTxn::commitbuildsCommitHistoryMeta, whose timestamp is the history entry'sunix_seconds(src/txn/write/commit.rs:113).src/txn/db/catalog/history.rs:151).Observed under
wasm-bindgen-test:A consumer hits this today: NodeDB-Lite's WASM test
array::create_put_slice_roundtripfails at its first write for this reason.Change
clock::unix_seconds()owns the target split:js_sys::Date::now()on the OPFS build, std everywhere else (wasm32-wasip1included), and0for a wasm build without the JS bindings — the history ordering tolerates that instead of panicking.wasm-smoke/is a separate crate because the pagedb dev-dependencies (tokiort-multi-thread, tempfile) do not compile for wasm32, and Cargo builds every dev-dependency for a crate's test targets. Two tests: a commit, and a commit under age retention.wasm-testsCI job runs them under node, so the compile-only wasm job is no longer the last line of defence.Crash point
Per CONTRIBUTING: the timestamp is metadata on the commit-history entry; the commit point is the A/B header write and is unchanged. A crash before the history write leaves the previous entry, after it the new one. Recovery does not read the clock.
Evidence
time not implemented on this platformcargo checknative /--target wasm32-unknown-unknown --features opfs/--target wasm32-wasip1unix_secondscallers (c2g, exact)Fixes #40.