Repository navigation
Conversation
Multiplying Date.getTime() by 1_000_000 as a float before converting to BigInt causes IEEE 754 precision loss once the product exceeds Number.MAX_SAFE_INTEGER (~9007T, which ms * 1e6 hits around 2255 AD). The correct pattern already exists in convertDateToNanoseconds(): BigInt(date.getTime()) * BigInt(1_000_000) Apply it consistently to the three call sites that still use the float-multiply pattern (getNowInNanoseconds, calculateDurationFromStart, and the runEngineHandlers retry-event recordEvent call).
…for cancelled runs booleanHelpersFromRunStatus omitted CANCELED from failedStatuses, so realtime run shapes returned isCompleted: false and isFailed: false for cancelled runs. The REST API presenter correctly sets both to true. Consumers checking run.isCompleted to gate teardown logic silently skipped cancelled runs.
|
|
Hi @okxint, 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. |
|
Caution Review failedThe pull request is closed.
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. |
calculateNextRetryDelay() returns undefined when retries are exhausted and a number (including 0) when a retry should happen. The !delay guard was coercing 0 to false, causing runs configured with an immediate retry (delay of 0ms) to be treated as having no retries left and failed prematurely. Switch to explicit undefined checks in both the OOM retry path and the general retry path.
There was a problem hiding this comment.
🔍 Three unrelated fixes in one PR
The PR describes zero-delay retries but also changes trace timestamps and Realtime status helpers. The contribution guide requires one issue per PR.
Was this helpful? React with 👍 or 👎 to provide feedback.
| const delay = calculateNextRetryDelay(oomResult.retrySettings, attemptNumber ?? 1); | ||
|
|
||
| if (!delay) { | ||
| if (delay === undefined) { |
There was a problem hiding this comment.
🔴 Immediate OOM retries exceed attempt limits
When a run reaches its per-run limit and runs out of memory, retryOutcomeFromCompletion can still schedule a zero-delay retry. retryOOMOnMachine uses the task’s retry settings instead of the run’s attempt limit. The extra attempt runs on the fallback machine.
Learn more
The trigger service passes the caller’s maxAttempts to the engine. Dequeue preserves that per-run limit and saves the task’s original retry settings separately. The OOM lookup reads only the task settings, and the ordinary attempt-limit check runs after the OOM branch has already returned. Previously a zero delay stopped that branch before it could use the wrong limit. Now attempt completion requeues the run on the fallback machine.
Example: Deploy a task with retry.maxAttempts: 3, minTimeoutInMs: 0, and an OOM fallback machine. Trigger it with { maxAttempts: 1 } and let the first attempt run out of memory. The engine queues a second attempt instead of ending the run.
Recommended fix: Include the run’s maxAttempts in retryOOMOnMachine’s existing read and use it as the effective attempt limit when present, without discarding the valid zero delay. Add an engine test that compares an immediate OOM retry with and without a one-attempt override.
Was this helpful? React with 👍 or 👎 to provide feedback.
| const waitingStatuses = ["WAITING"]; | ||
| const executingStatuses = ["DEQUEUED", "EXECUTING"]; | ||
| const failedStatuses = ["FAILED", "CRASHED", "SYSTEM_FAILURE", "EXPIRED", "TIMED_OUT"]; | ||
| const failedStatuses = ["FAILED", "CRASHED", "SYSTEM_FAILURE", "EXPIRED", "TIMED_OUT", "CANCELED"]; |
There was a problem hiding this comment.
🟡 Canceled runs reported as failures
When a subscriber receives a canceled run, booleanHelpersFromRunStatus now emits isFailed: true alongside isCancelled: true. The Realtime run contract treats cancellation separately from failure.
Learn more
subscribeToRun delivers run objects with status helpers, and the Realtime contract lists failure statuses separately from cancellation. RunSubscription closes based on finishedAt, not isFailed, so marking the run failed is not necessary to close its subscription.
Example: Cancel a run while subscribed to it. The final update reports status: "CANCELED", isCancelled: true, and now isFailed: true, so a subscription that routes failed runs to a failure handler also routes cancellations there.
Recommended fix: Keep CANCELED out of failedStatuses. If the intended behavior is to mark canceled runs complete, add cancellation to the isCompleted expression separately and update its documentation.
Was this helpful? React with 👍 or 👎 to provide feedback.
| const waitingStatuses = ["WAITING"]; | ||
| const executingStatuses = ["DEQUEUED", "EXECUTING"]; | ||
| const failedStatuses = ["FAILED", "CRASHED", "SYSTEM_FAILURE", "EXPIRED", "TIMED_OUT"]; | ||
| const failedStatuses = ["FAILED", "CRASHED", "SYSTEM_FAILURE", "EXPIRED", "TIMED_OUT", "CANCELED"]; |
There was a problem hiding this comment.
🔍 Missing changeset for Realtime status
The package changelog has no changeset for the Realtime status change. The release-note rules require one for user-visible package behavior.
Was this helpful? React with 👍 or 👎 to provide feedback.
| type: fix | ||
| --- | ||
|
|
||
| Fix OTLP trace timestamps losing precision for runs after approximately 2255 AD. Timestamps are now computed with full 64-bit integer arithmetic. |
There was a problem hiding this comment.
🔍 Misleading date in timestamp release note
The old timestamp conversion already rounds some present-day dates. The fix affects server-generated event times, not incoming OTLP timestamps.
Was this helpful? React with 👍 or 👎 to provide feedback.
calculateNextRetryDelay()returnsundefinedwhen retries are exhausted and a number (including0) when a retry should occur.Two guards in
retrying.tsused!delayto check for no more retries, but this coerces0tofalse, so a task configured with an immediate retry (delay = 0ms) gets incorrectly failed instead of retried.OOM retry path (line 70):
General retry path (line 183):
This matches how
calculateNextRetryDelaysignals "no retry" (by returningundefined) vs "retry immediately" (returning0).