`performance` still breaks in Node 15
vrugtehagel opened this issue ยท 5 comments
We're experiencing a similar problem not in Node but using LiquidJS as a WASM module compiled with Javy which doesn't seem to have access to monotonic timers out of the box.
The only easy fix I found was to define a globalThis.performance
object with a now
method that always returns 0 since we're already limiting the run time externally.
I guess, one solution is to use something like
const startupTime = globalThis.performance ? 0 : (globalThis.Date?.now() ?? 0);
const now = () => {
if(globalThis.performance){
return globalThis.performance.now();
}
const current = globalThis.Date?.now() ?? 0;
return current - startupTime;
}
and then we can drop the node:perf_hooks
imports altogether. I know Date.now()
is not as accurate, but better than nothing anyway. And this also fails gracefully if you are using an environment that has no timers at all.
@vrugtehagel agreed. We can fallback to Date.now()
for platforms don't provide the performance
global variable. Let me work on a fix.
the test runner doesn't even want to run on Node 15
I can run jest locally with Node@15, I'll try include it on CI.
๐ This issue has been resolved in version 10.16.3 ๐
The release is available on:
Your semantic-release bot ๐ฆ๐