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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • bson-2.6.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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
            Reporter:
            Patrick Freed
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: