fix: prevent IEEE 754 precision loss in OTLP nanosecond timestamps#3521
fix: prevent IEEE 754 precision loss in OTLP nanosecond timestamps#3521cybertron288 wants to merge 1 commit intotriggerdotdev:mainfrom
Conversation
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThis PR fixes IEEE 754 precision loss in OTLP nanosecond timestamp conversions. The fix converts epoch milliseconds to Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi @cybertron288, 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. |
Closes #3292
What
Convert epoch milliseconds to
BigIntbefore multiplying by1_000_000in four OTLP-event timestamp computations, so the multiplication happens in BigInt-land instead of as a JS Number.Why
epoch_ms * 1_000_000(≈1.7e18) exceedsNumber.MAX_SAFE_INTEGER(~9e15), causing ~256ns rounding errors in roughly 0.2% of cases. This already-correct pattern (BigInt(ms) * BigInt(1_000_000)) exists inconvertDateToNanoseconds()in the same file — the four other call sites just hadn't adopted it. See issue #3292 for the full breakdown.Affected lines:
apps/webapp/app/v3/eventRepository/common.server.ts:24—getNowInNanoseconds()apps/webapp/app/v3/eventRepository/common.server.ts:38—calculateDurationFromStart()apps/webapp/app/v3/eventRepository/index.server.ts:218—recordRunDebugLog()startTimeapps/webapp/app/v3/runEngineHandlers.server.ts:432— retry event recordingNotes
.server-changes/entry added perapps/webapp/CLAUDE.mdconventions (server-only change, no public package touched).