Skip to content

fix: OTLP nanosecond timestamp overflow from IEEE 754 precision loss#3383

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

fix: OTLP nanosecond timestamp overflow from IEEE 754 precision loss#3383
avasis-ai wants to merge 1 commit intotriggerdotdev:mainfrom
avasis-ai:fix/otlp-nanosecond-timestamp-overflow-3292

Conversation

@avasis-ai
Copy link
Copy Markdown

Summary

Fixes #3292

Several places convert epoch milliseconds to nanoseconds by multiplying before converting to BigInt:

// Bug: multiplication in float-land (~1.7e18 > MAX_SAFE_INTEGER ~9e15)
BigInt(date.getTime() * 1_000_000)

// Fix: convert to BigInt first, then multiply
BigInt(date.getTime()) * 1_000_000n

This matches the existing convertDateToNanoseconds() helper in the same file, which already does this correctly.

Files changed

  • apps/webapp/app/v3/eventRepository/common.server.tsgetNowInNanoseconds() and calculateDurationFromStart()
  • apps/webapp/app/v3/eventRepository/index.server.tsrecordRunEvent() startTime
  • apps/webapp/app/v3/runEngineHandlers.server.ts — retry event recording startTime

Impact

~256ns errors in ~0.2% of timestamp conversions due to IEEE 754 precision loss. Low severity but prevents potential span ordering edge cases.

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
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 15, 2026

⚠️ No Changeset found

Latest commit: c10ca6d

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

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.

@github-actions github-actions bot closed this Apr 15, 2026
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

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

2 participants