You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OTLP nanosecond timestamp overflow in webapp event repository #3292
Several places in the webapp multiply epoch milliseconds by 1,000,000 before converting to BigInt, which causes IEEE 754 precision loss (~256ns errors in ~0.2% of cases). The result exceeds Number.MAX_SAFE_INTEGER (~9e15) since epoch-ms * 1e6 is ~1.7e18.
The correct pattern is BigInt(ms) * BigInt(1_000_000) (multiplication after BigInt conversion). This already exists in convertDateToNanoseconds() in the same file - the buggy functions just didn't use it.
Impact: Low. The errors are +-256 nanoseconds, which is unlikely to cause visible issues. But it's an easy fix and prevents any edge cases with span ordering.
Context: Found during compute workload manager PR review (#3114). The supervisor's msToNano() was fixed in that PR using a split approach that also preserves sub-ms precision from performance.now() arithmetic.
I've submitted PR #3381 fixing all instances of the BigInt overflow pattern, including the one at runEngineHandlers.server.ts:432 that was missed in the previous PR #3378. However, the PR was auto-closed because I need to be vouched as a contributor. Could a maintainer please help with that?
Hi! I've written a fix for this precision loss issue and submitted PR #4499. However, the PR was automatically closed because I am not on the vouched contributors list yet. Could a maintainer please vouch for me so I can reopen the PR? Thank you!
Hi — noticed this is still open and the buggy BigInt(ms * 1e6) pattern is still on main in eventRepository/common.server.ts. Prior spam PRs were closed; no open claim.
Happy to ship a clean TS fix: switch all ms→ns sites to BigInt(ms) * BigInt(1_000_000) (matching convertDateToNanoseconds), plus a small regression test.
If useful, could you /bounty $125 on this issue via Algora? I’ll exclusive-PR within 48–72h as @robinthedev-a11y.
Happy to adjust amount/scope. Thanks for the OSS + past Algora payouts.
🔍 Root Cause Analysis & Complete Fix across all 4 Call Sites
Hey team,
I investigated the OTLP nanosecond timestamp precision loss on the current main branch.
Why this happens
In JavaScript, standard numbers are IEEE 754 64-bit floats with Number.MAX_SAFE_INTEGER = 9,007,199,254,740,991 (9e15). An epoch millisecond timestamp (1.78e12) multiplied by 1_000_000 produces ~1.78e18, which far exceeds Number.MAX_SAFE_INTEGER. Multiplying prior to BigInt conversion causes truncation/rounding errors (±256ns) in ~0.2% of timestamps.
The safe pattern (already used in convertDateToNanoseconds) is to cast to BigInt first: BigInt(ms) * BigInt(1_000_000)
Hey team — I put together a fix and colocated unit tests for this in PR #5027 (auto-closed by the vouch bot as a first-time contributor here):
Updated getNowInNanoseconds and calculateDurationFromStart in common.server.ts to use convertDateToNanoseconds so epoch ms is converted to BigInt before multiplying by 1_000_000.
Updated the remaining BigInt(ms * 1_000_000) sites in index.server.ts and
unEngineHandlers.server.ts to BigInt(ms) * BigInt(1_000_000).
Added real-clock unit tests in �pps/webapp/app/v3/eventRepository/common.server.test.ts (and resolved both Devin review notes in 33f68e7).
Could a maintainer vouch @oziass so #5027 can be reopened? Thanks!
Activity
fix: convert to BigInt before multiplying to avoid nanosecond precisi…
fix: convert epoch-ms to BigInt before nanosecond multiplication
fix: prevent IEEE 754 precision loss in OTLP nanosecond timestamps
fix: convert to BigInt before nanosecond multiplication in all instances
fix: OTLP nanosecond timestamp overflow from IEEE 754 precision loss
aayushbaluni commentedon Apr 15, 2026
I've submitted PR #3381 fixing all instances of the BigInt overflow pattern, including the one at
runEngineHandlers.server.ts:432that was missed in the previous PR #3378. However, the PR was auto-closed because I need to be vouched as a contributor. Could a maintainer please help with that?fix: prevent nanosecond overflow in OTLP timestamps
fix(webapp): fix BigInt nanosecond precision loss in retry event star…
AkhilTrivediX commentedon Aug 4, 2026
Hi! I've written a fix for this precision loss issue and submitted PR #4499. However, the PR was automatically closed because I am not on the vouched contributors list yet. Could a maintainer please vouch for me so I can reopen the PR? Thank you!
robinthedev-a11y commentedon Sep 9, 2026
Hi — noticed this is still open and the buggy
BigInt(ms * 1e6)pattern is still on main ineventRepository/common.server.ts. Prior spam PRs were closed; no open claim.Happy to ship a clean TS fix: switch all ms→ns sites to
BigInt(ms) * BigInt(1_000_000)(matchingconvertDateToNanoseconds), plus a small regression test.If useful, could you
/bounty $125on this issue via Algora? I’ll exclusive-PR within 48–72h as@robinthedev-a11y.Happy to adjust amount/scope. Thanks for the OSS + past Algora payouts.
bilalhusain-dev commentedon Oct 12, 2026
🔍 Root Cause Analysis & Complete Fix across all 4 Call Sites
Hey team,
I investigated the OTLP nanosecond timestamp precision loss on the current
mainbranch.Why this happens
In JavaScript, standard numbers are IEEE 754 64-bit floats with
Number.MAX_SAFE_INTEGER = 9,007,199,254,740,991(9e15). An epoch millisecond timestamp (1.78e12) multiplied by1_000_000produces ~1.78e18, which far exceedsNumber.MAX_SAFE_INTEGER. Multiplying prior toBigIntconversion causes truncation/rounding errors (±256ns) in ~0.2% of timestamps.The safe pattern (already used in
convertDateToNanoseconds) is to cast toBigIntfirst:BigInt(ms) * BigInt(1_000_000)Proposed Fix (All 4 Affected Locations)
fix(webapp): convert epoch ms to BigInt before nanosecond multiplication
oziass commentedon Oct 14, 2026
/attempt #3292
Hey team — I put together a fix and colocated unit tests for this in PR #5027 (auto-closed by the vouch bot as a first-time contributor here):
unEngineHandlers.server.ts to BigInt(ms) * BigInt(1_000_000).
Could a maintainer vouch @oziass so #5027 can be reopened? Thanks!