fix: convert to BigInt before nanosecond multiplication (all instances)#3381
fix: convert to BigInt before nanosecond multiplication (all instances)#3381aayushbaluni wants to merge 1 commit intotriggerdotdev:mainfrom
Conversation
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
|
|
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. |
|
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 The bug causes IEEE 754 precision loss when computing nanosecond timestamps — Could a maintainer please vouch me so this can be reviewed? Happy to answer any questions about the fix. |
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 exceedNumber.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:
Files changed
apps/webapp/app/v3/eventRepository/common.server.ts-getNowInNanoseconds,calculateDurationFromStart,calculateDurationFromStartJsDateapps/webapp/app/v3/eventRepository/index.server.ts-recordRunDebugLogapps/webapp/app/v3/runEngineHandlers.server.ts- startTime calculation (previously missed)