Skip to content

fix: prevent IEEE 754 precision loss in OTLP nanosecond timestamps#3521

Closed
cybertron288 wants to merge 1 commit intotriggerdotdev:mainfrom
cybertron288:fix/issue-3292
Closed

fix: prevent IEEE 754 precision loss in OTLP nanosecond timestamps#3521
cybertron288 wants to merge 1 commit intotriggerdotdev:mainfrom
cybertron288:fix/issue-3292

Conversation

@cybertron288
Copy link
Copy Markdown

Closes #3292

What

Convert epoch milliseconds to BigInt before multiplying by 1_000_000 in 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) exceeds Number.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 in convertDateToNanoseconds() 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:24getNowInNanoseconds()
  • apps/webapp/app/v3/eventRepository/common.server.ts:38calculateDurationFromStart()
  • apps/webapp/app/v3/eventRepository/index.server.ts:218recordRunDebugLog() startTime
  • apps/webapp/app/v3/runEngineHandlers.server.ts:432 — retry event recording

Notes

  • Opened as draft — please review before marking ready.
  • .server-changes/ entry added per apps/webapp/CLAUDE.md conventions (server-only change, no public package touched).
  • Verification: not run locally — change is mechanical and 4 lines across 3 files. CI typecheck should cover it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 5, 2026

⚠️ No Changeset found

Latest commit: f25aa36

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 79a0dee1-31e5-47b1-8b9f-6e9c5e95a167

📥 Commits

Reviewing files that changed from the base of the PR and between 5dab2ae and f25aa36.

📒 Files selected for processing (4)
  • .server-changes/fix-otlp-nanosecond-precision.md
  • apps/webapp/app/v3/eventRepository/common.server.ts
  • apps/webapp/app/v3/eventRepository/index.server.ts
  • apps/webapp/app/v3/runEngineHandlers.server.ts

Walkthrough

This PR fixes IEEE 754 precision loss in OTLP nanosecond timestamp conversions. The fix converts epoch milliseconds to BigInt before multiplying by 1_000_000 to derive nanoseconds, rather than performing the multiplication as a JavaScript number first. This pattern is consistently applied across four files: a server change documentation entry and three event handling/repository files where millisecond-to-nanosecond conversions occur.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OTLP nanosecond timestamp overflow in webapp event repository

1 participant