Skip to content

fix: convert to BigInt before nanosecond multiplication (all instances)#3381

Closed
aayushbaluni wants to merge 1 commit intotriggerdotdev:mainfrom
aayushbaluni:fix/3292-bigint-overflow-all-instances
Closed

fix: convert to BigInt before nanosecond multiplication (all instances)#3381
aayushbaluni wants to merge 1 commit intotriggerdotdev:mainfrom
aayushbaluni:fix/3292-bigint-overflow-all-instances

Conversation

@aayushbaluni
Copy link
Copy Markdown

Summary

Fixes #3292

This is a resubmission of #3378 which was closed because it missed one instance of the bug. This PR fixes ALL instances.

Root Cause

Multiple functions compute nanosecond timestamps as BigInt(milliseconds * 1_000_000). When milliseconds exceed Number.MAX_SAFE_INTEGER / 1_000_000, the multiplication overflows IEEE 754 precision before the BigInt conversion.

Fix

Convert to BigInt before multiplication in all instances:

BigInt(milliseconds) * BigInt(1_000_000)

Files changed

  • apps/webapp/app/v3/eventRepository/common.server.ts - getNowInNanoseconds, calculateDurationFromStart, calculateDurationFromStartJsDate
  • apps/webapp/app/v3/eventRepository/index.server.ts - recordRunDebugLog
  • apps/webapp/app/v3/runEngineHandlers.server.ts - startTime calculation (previously missed)

Fixes triggerdotdev#3292

Multiple functions compute nanosecond timestamps as
BigInt(milliseconds * 1_000_000). When milliseconds exceed
Number.MAX_SAFE_INTEGER / 1_000_000 (≈ 9.007e9, i.e. any date
after ~1970-04-15), the multiplication overflows IEEE 754 precision
before the BigInt conversion captures it.

Fix all instances (including runEngineHandlers.server.ts:432 which
was missed in the previous PR triggerdotdev#3378) by converting to BigInt first:
BigInt(milliseconds) * BigInt(1_000_000)

Made-with: Cursor
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 15, 2026

⚠️ No Changeset found

Latest commit: 65e5e38

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 @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://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

@aayushbaluni
Copy link
Copy Markdown
Author

Hi! This PR was auto-closed because I'm not in the vouched users list. I understand the policy from CONTRIBUTING.md.

This is a resubmission of #3378 which was closed because it missed one instance of the BigInt overflow bug. This PR fixes ALL instances including the previously missed runEngineHandlers.server.ts:432.

The bug causes IEEE 754 precision loss when computing nanosecond timestamps — BigInt(milliseconds * 1_000_000) overflows before BigInt conversion. The fix converts to BigInt first: BigInt(milliseconds) * BigInt(1_000_000).

Could a maintainer please vouch me so this can be reviewed? Happy to answer any questions about the fix.

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