Skip to content

fix: respect maxElapsed in ExponentialBackoff.execute#3760

Closed
nikhil-shukl wants to merge 1 commit into
triggerdotdev:mainfrom
nikhil-shukl:codex/fix-backoff-max-elapsed
Closed

fix: respect maxElapsed in ExponentialBackoff.execute#3760
nikhil-shukl wants to merge 1 commit into
triggerdotdev:mainfrom
nikhil-shukl:codex/fix-backoff-max-elapsed

Conversation

@nikhil-shukl
Copy link
Copy Markdown

Closes #3726

✅ Checklist

  • I have followed every step in the contributing guide
  • The PR title follows the convention.
  • I ran and tested the code works

Testing

Ran the focused backoff test:

vitest run packages/core/test/backoff.test.ts --config vitest.temp.config.mjs

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 27, 2026

🦋 Changeset detected

Latest commit: ddd000b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 32 packages
Name Type
@trigger.dev/core Patch
@trigger.dev/build Patch
trigger.dev Patch
@trigger.dev/plugins Patch
@trigger.dev/python Patch
@trigger.dev/redis-worker Patch
@trigger.dev/schema-to-json Patch
@trigger.dev/sdk Patch
@internal/cache Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@trigger.dev/rbac Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/schedule-engine Patch
@internal/testcontainers Patch
@internal/tracing Patch
@internal/tsql Patch
@internal/zod-worker Patch
references-ai-chat Patch
d3-chat Patch
references-d3-openai-agents Patch
references-nextjs-realtime Patch
references-realtime-hooks-test Patch
references-realtime-streams Patch
references-telemetry Patch
@internal/sdk-compat-tests Patch
@trigger.dev/react-hooks Patch
@trigger.dev/rsc Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 809e509e-eee1-470a-befa-b5154e131c10

📥 Commits

Reviewing files that changed from the base of the PR and between 37eeaa3 and ddd000b.

📒 Files selected for processing (3)
  • .changeset/respect-backoff-max-elapsed.md
  • packages/core/src/v3/apps/backoff.ts
  • packages/core/test/backoff.test.ts

Walkthrough

This PR modifies ExponentialBackoff.execute() in the core package to enforce a previously unenforced timeout constraint. The method now tracks accumulated elapsed time during the retry loop and immediately returns a timeout failure if callback execution pushes the total past the configured maxElapsed threshold. A test verifies this behavior by running a slow callback against a very short maxElapsed window and confirming the backoff terminates early with the expected timeout result. The changeset documents the behavior update for the next patch release.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 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

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

@github-actions
Copy link
Copy Markdown
Contributor

Hi @nikhil-shukl, 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 May 27, 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 found 1 potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 maxElapsed wall-clock check is bypassed when callback throws AttemptTimeout

The new maxElapsed check at line 343 is placed after the try/catch/finally block. When the callback throws an AttemptTimeout (line 335-337), the continue statement skips all code after the try/catch/finally, including the new maxElapsed check. Although the finally block still executes and correctly updates elapsedMs, the actual check is never evaluated.

This means if a caller uses both attemptTimeoutMs and maxElapsed, and every attempt times out, the loop will never exit early due to maxElapsed. It will only stop when retryAsync's delay-based check (which doesn't account for callback execution time, packages/core/src/v3/apps/backoff.ts:127-130) or maxRetries terminates the generator. For example, with maxElapsed: 10 (seconds), attemptTimeoutMs: 3000, and maxRetries: 100, the loop could run for up to ~300 seconds instead of stopping after 10.

(Refers to lines 335-337)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

bug(v3): maxElapsed timeout boundary bypassed in ExponentialBackoff.execute

1 participant