fix: OTLP nanosecond timestamp overflow from IEEE 754 precision loss#3383
fix: OTLP nanosecond timestamp overflow from IEEE 754 precision loss#3383avasis-ai wants to merge 1 commit intotriggerdotdev:mainfrom
Conversation
Convert epoch milliseconds to BigInt before multiplying by 1,000,000 to avoid IEEE 754 precision loss. The result of epoch_ms * 1e6 (~1.7e18) exceeds Number.MAX_SAFE_INTEGER (~9e15), causing ~256ns errors. Fixes triggerdotdev#3292
|
|
Hi @avasis-ai, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details. |
Summary
Fixes #3292
Several places convert epoch milliseconds to nanoseconds by multiplying before converting to
BigInt:This matches the existing
convertDateToNanoseconds()helper in the same file, which already does this correctly.Files changed
apps/webapp/app/v3/eventRepository/common.server.ts—getNowInNanoseconds()andcalculateDurationFromStart()apps/webapp/app/v3/eventRepository/index.server.ts—recordRunEvent()startTimeapps/webapp/app/v3/runEngineHandlers.server.ts— retry event recording startTimeImpact
~256ns errors in ~0.2% of timestamp conversions due to IEEE 754 precision loss. Low severity but prevents potential span ordering edge cases.