llrt
llrt copied to clipboard
process.hrtime.bigint() returns result inconsistent with node.js runtime
// teat.js
console.log(process.hrtime.bigint());
https://github.com/awslabs/llrt/blob/b01b7aab8a8182b05be57cfa297235250e58817f/src/process.rs#L40
Resolution should be the same, right now is micros rather than nanos. So we'll need to fix it!
As a workaround I force convert to BigInt
diff --git a/src/internal/clock.ts b/src/internal/clock.ts
index 1277d2cd1b0454847bcb611ce22cd9beb3907398..eab666dfa2e5f1dfbcfbf405bc39e66d03cf7aaf 100644
--- a/src/internal/clock.ts
+++ b/src/internal/clock.ts
@@ -61,8 +61,8 @@ const processOrPerformanceNow = (function() {
if (!processHrtime) {
return performanceNowNanos
}
- const origin = performanceNowNanos() - processHrtime.bigint()
- return () => origin + processHrtime.bigint()
+ const origin = performanceNowNanos() - BigInt(processHrtime.bigint())
+ return () => origin + BigInt(processHrtime.bigint())
})()
/** @internal */