Skip to content

wasm: SystemTime::now() in the write-commit path panics on wasm32-unknown-unknown #42

Description

@EnRaiha

Summary

The NodeDB-Lite WASM array smoke test cannot run to completion on
wasm32-unknown-unknown, because pagedb reads the wall clock through
SystemTime::now(), which panics on that target with "time not implemented on
this platform"
. The panic happens inside the storage transaction, before the
test reaches any engine code.

Evidence

nodedb-lite-wasm/tests/array.rs::create_put_slice_roundtrip, run under the
Node wasm-bindgen runner with full symbols (--profile debugging):

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

at <std::time::SystemTime>::now
at pagedb::txn::write::commit::<impl WriteTxn<V>>::commit_body::{{closure}}

Reproduced against nodedb-lite @ 59dad1c, with the shared nodedb-* crates
patched to a local nodedb worktree so the array HLC routes through the
target-split clock helper. The blame frame is pagedb::txn::write, not the
array engine — the array's own clock call is js_sys::Date::now() on that
target and is not in the stack.

Why it matters beyond one test

pagedb is the storage layer under every Lite WASM build, so any wasm code path
that commits a write transaction reaches this. It also blocks the only existing
runtime coverage for the shared crates' browser clock: array.rs is the test
that exercised the array HLC that panicked in the first place, so while pagedb
reads SystemTime::now() directly, that coverage cannot be restored.

Suggested direction

The same target split the shared crates use: js_sys::Date::now() on
wasm32-unknown-unknown, std elsewhere. nodedb-types::clock::since_epoch()
now exists for exactly this and is the helper the shared crates route through,
though pagedb is a separately published crate and may prefer its own.

Environment

  • wasm32-unknown-unknown, Node 22 via wasm-bindgen-test-runner
  • nodedb-lite @ 59dad1c, nodedb shared crates @ local worktree
  • run: CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner cargo test --profile debugging -p nodedb-lite-wasm --target wasm32-unknown-unknown --test array

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions