Coder Social home page Coder Social logo

Comments (7)

mattyg avatar mattyg commented on May 28, 2024 2

i found that chrono::prelude::Utc::now() also causes a runtime error. (hc 0.2.3-rc.1)

Yeah we can't get chrono timestamps in the wasm guest (need to ask the host for timestamp) -- that's also why Timestamp::now() panics (it's just calling Utc::now() under the hood). We have a function sys_time() for use within the wasm guest.

I think the only issue here is that Timestamp::now() either shouldn't be exposed via the hdk, or should have a feature flag to switch its implementation to use sys_time() when compiled for wasm targets

from holochain.

mattyg avatar mattyg commented on May 28, 2024 1

I see, then yeah it seems like there is just something funky with the feature flags being passed into kitsune_p2p_timestamp when running holochain feature test_utils (although that shouldn't affect the flags on the hdk used within the dna, right?)

Also the docs for Timestamp::now() reference a different implementation in holochain_types that doesn't actually exist.

from holochain.

mattyg avatar mattyg commented on May 28, 2024

It looks like the feature full from kitsune_p2p_timestamp needs to get bubbled up to the holochain crate and set as part of it's own test_utils feature.

Edit: maybe not, I think I'm confused -- is there supposed to be a Timestamp::now() implementation that works in wasm? Or are we supposed to use sys_time() -- if thats the case maybe it just needs to be removed from hdk / hdi

from holochain.

jost-s avatar jost-s commented on May 28, 2024

Hi @mattyg, yeah, I've noticed this doesn't work too. Thanks for the reproduction, it's reproducible.

According to the Timestamp docs it's not supposed to work in WASMs https://github.com/holochain/holochain/blob/develop/crates/kitsune_p2p/timestamp/src/lib.rs#L46-L47

The docs contradict the fact there is a Timestamp::now(), so needs updating too.

I don't know what's the recommended way here, but you can use sys_time as well as chrono::prelude::Utc::now().timestamp().

from holochain.

nphias avatar nphias commented on May 28, 2024

i found that chrono::prelude::Utc::now() also causes a runtime error. (hc 0.2.3-rc.1)

from holochain.

ThetaSinner avatar ThetaSinner commented on May 28, 2024

I've got a fix for this. It is feature indeed an unhelpful combination of features through dependency crates. I found a reasonably nice solution in holochain_zome_types that resolves the issue, with a few other tidy-ups.

I even managed to make a test which ensures this stays unavailable which I think is pretty cool, because I get excited by testing tools / libraries that do that kind of thing :D

from holochain.

ThetaSinner avatar ThetaSinner commented on May 28, 2024

Back-ported in #3121

from holochain.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.