Skip to content

wasm: every commit reads SystemTime::now() for the history entry \u2014 the first write panics #40

Description

@EnRaiha

Version / build tested against

NodeDB-Lab/pagedb @ e4a6902 (main, 2026-09-17), wasm32-unknown-unknown.

Deployment mode

Embedded — wasm32-unknown-unknown, memory VFS and OPFS.

Engine(s) involved

Storage (txn commit path).

Summary

WriteTxn::commit reads the wall clock for CommitHistoryMeta's timestamp, and the age-based
retention policy reads it for the pruning threshold. wasm32-unknown-unknown has no std clock, so
SystemTime::now() panics with time not implemented on this platform and the first commit from
an embedded build fails
. A consumer (NodeDB-Lite's WASM test array::create_put_slice_roundtrip)
fails at its first write for this reason.

Steps to reproduce

// wasm-smoke/tests/commit_smoke.rs, run under node
let db = Db::open(MemVfs::new(), kek, 4096, realm, opts).await?;
let mut w = db.begin_write().await?;
w.put(b"k", b"v").await?;
w.commit().await?;          // ← panics

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

Expected behavior

A commit completes on wasm32-unknown-unknown; the history timestamp comes from the host clock
(js_sys::Date::now()) or degrades to 0 when no clock exists.

Actual behavior

Panic at the two sites: src/txn/write/commit.rs:113, src/txn/db/catalog/history.rs:151.

What actually happened? (check all that are true)

  • core broken no workaround (embedded builds cannot write at all)

Proposed severity

SEV-2 — High: a supported target cannot perform its primary operation.

Reproducibility

Always — every commit on wasm32-unknown-unknown.

Last known-good version / commit (if a regression)

Unknown.

Environment & logs

Linux x86_64 host, node runner; wasm-bindgen-test; memory VFS. Red proof: both smoke tests panic
before the fix, pass after.

Before submitting

  • searched for duplicates
  • reproduced on current main
  • not a security issue

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

    sev:2-highMajor functionality broken; no acceptable workaroundtype:bugA defect — broken, incorrect, or lost data

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions