Uploaded image for project: 'Rust Driver'
  1. Rust Driver
  2. RUST-504

ObjectId::new() doesn't work on wasm

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • bson-2.6.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      Because ObjectId needs to get the current time, it panics in wasm, which can't get the current time via std (see: https://github.com/rust-lang/rust/issues/48564).

      Issue originally filed by sinhpham on GitHub (https://github.com/mongodb/bson-rust/issues/199):

      Due to using std::time::SystemTime.

      A potential solution is exposing a new_with_timestamp(n_secs_since_unix_epoch: u32) -> Self constructor. People who want to run on wasm can supply their own timestamp.

            Assignee:
            abraham.egnor@mongodb.com Abraham Egnor
            Reporter:
            patrick.freed@mongodb.com Patrick Freed
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: