timeOrigin = undefined on Deno Deploy
Hello guys
When i deploy my code on Deno Deploy, I have this error in the logs and it says "ERROR: RangeError: Invalid time value at Date.toISOString ()". It happens because of this line in my code
const start = performance.timeOrigin; //undefined
I've tried to use Date.now() instead of performance.timeOrigin, and it worked.
*Btw performance.now() working as well.
Does someone know what is the possible solution? Deno on latest version.
It deployes successfully, but on Deno logs this error.
1 Reply
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the information you've provided, it seems that
performance.timeOrigin
is returning undefined
, which is not expected behavior as performance.timeOrigin
should return the time value representing the start time of the performance measurement.
Since performance.timeOrigin
is undefined, attempting to use it as a timestamp for a Date
object would indeed result in a RangeError
because Date
expects a valid timestamp.
You mentioned that using Date.now()
works, which is a good alternative to get the current timestamp. performance.now()
is also working for you, which is great for measuring time intervals with high resolution.
The advice I'm providing is not based on the Deno documentation, so please double-check the accuracy of this advice. If performance.timeOrigin
is not behaving as expected on Deno Deploy, it might be a platform-specific issue or a bug. You might want to consider reporting this behavior to the Deno Deploy team or checking if there are any open issues related to this on the Deno issue tracker.
In the meantime, using Date.now()
as you have done is a valid workaround for getting the current timestamp. If you need a high-resolution start time for performance measurements, you might need to establish your own baseline using Date.now()
or performance.now()
at the start of your script.