Skip to content

feat(sdk): replace maxDuration with maxComputeSeconds (user-facing rename) - #4436

Closed
deepshekhardas wants to merge 1 commit into
triggerdotdev:mainfrom
deepshekhardas:fix/max-compute-seconds
Closed

feat(sdk): replace maxDuration with maxComputeSeconds (user-facing rename)#4436
deepshekhardas wants to merge 1 commit into
triggerdotdev:mainfrom
deepshekhardas:fix/max-compute-seconds

Conversation

@deepshekhardas

Copy link
Copy Markdown

Rebased version of #3533. Adds maxComputeSeconds as the user-facing replacement for maxDuration on defineConfig, task definitions, and trigger options. maxDuration stays JSDoc-deprecated and accepted; if both are set maxComputeSeconds wins. Updated init templates and added unit tests. Closes #3533.

@changeset-bot

changeset-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 80cb649

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

This PR includes changesets to release 27 packages
Name Type
@trigger.dev/core Patch
@trigger.dev/sdk Patch
trigger.dev Patch
@trigger.dev/build Patch
@trigger.dev/python Patch
@trigger.dev/redis-worker Patch
@trigger.dev/schema-to-json Patch
@internal/cache Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@internal/metrics-pipeline Patch
@trigger.dev/rbac Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/run-store Patch
@internal/schedule-engine Patch
@trigger.dev/sso Patch
@internal/testcontainers Patch
@internal/tracing Patch
@internal/tsql Patch
@internal/dashboard-agent 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

@github-actions

Copy link
Copy Markdown
Contributor

Hi @deepshekhardas, 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 Jul 31, 2026

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

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.

Devin Review found 2 potential issues.

Open in Devin Review

Comment on lines +362 to +371
// Resolve maxComputeSeconds → maxDuration so plain-object exports that bypass
// defineConfig() still work. This mirrors the resolution defineConfig() applies
// at the SDK boundary; downstream CLI/runtime code only reads `maxDuration`.
const resolvedMaxDuration = config.maxComputeSeconds ?? config.maxDuration;
if (!resolvedMaxDuration) {
throw new Error(
`The "maxDuration" trigger.config option is now required, and must be at least 5 seconds.`
`The "maxComputeSeconds" trigger.config option is now required, and must be at least 5 seconds.`
);
}
config.maxDuration = resolvedMaxDuration;

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.

🟡 Project-wide compute limit is silently ignored for config files that don't use the helper wrapper

The project-wide compute limit written under the new name is only converted to the old name inside the command-line tool's copy of the settings (config.maxDuration = resolvedMaxDuration at packages/cli-v3/src/config.ts:371), not in the separate copy the task-indexing step loads, so tasks get no limit at all.

Impact: Users who export their settings as a plain object with only the new option get runs with no project-level compute cap, even though the tool reported the setting as valid.

Why the CLI-side mutation does not reach the indexed task manifests

validateConfig runs only inside the CLI process (packages/cli-v3/src/config.ts:196). The index workers re-import the user's built config module directly (importConfig at packages/cli-v3/src/entryPoints/dev-index-worker.ts:75-86, same in packages/cli-v3/src/entryPoints/managed-index-worker.ts) and then apply the project default with if (typeof config.maxDuration === "number") (packages/cli-v3/src/entryPoints/dev-index-worker.ts:147-152). For a config exported through defineConfig() the resolution happens at import time in the SDK, so it works; for a plain-object export — exactly the case the new comment at packages/cli-v3/src/config.ts:362-364 claims to support — the worker sees only maxComputeSeconds, maxDuration is undefined, and no per-task default is applied.

Prompt for agents
The CLI's validateConfig now resolves maxComputeSeconds into maxDuration by mutating its in-process copy of the config (packages/cli-v3/src/config.ts). However the dev and managed index workers (packages/cli-v3/src/entryPoints/dev-index-worker.ts and managed-index-worker.ts) import the user's built trigger.config module directly via importConfig() and read config.maxDuration to apply the project-level default to every task manifest. For configs exported as plain objects (bypassing defineConfig, which is the case the new comment says it supports), the worker's copy has only maxComputeSeconds, so the project-level limit is silently dropped. Consider resolving maxComputeSeconds -> maxDuration in the index workers too (or in a shared helper both the CLI and the entrypoints use) so the fallback works for every code path that reads the config.
Open in Devin Review

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

maxAttempts: options?.maxAttempts,
metadata: options?.metadata,
maxDuration: options?.maxDuration,
maxDuration: options ? resolveMaxComputeSeconds(options) : undefined,

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.

🔍 Chat/agent session trigger config still only reads maxDuration

packages/trigger-sdk/src/v3/ai.ts:10455-10460 and packages/trigger-sdk/src/v3/chat-server.ts:549-551 build a SessionTriggerConfig that forwards only maxDuration. These use their own option type (not TriggerOptions), so maxComputeSeconds isn't accepted there and the rename is incomplete for chat/agent session triggering. Not flagged as a bug because the type doesn't advertise the new field, but it's an inconsistency users may hit when the new name becomes the documented one.

Open in Devin Review

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

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

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 Plus

Run ID: a36058e2-3e7c-46b8-9add-a6ce717fa3dc

📥 Commits

Reviewing files that changed from the base of the PR and between debfa2b and 80cb649.

📒 Files selected for processing (17)
  • .changeset/max-compute-seconds.md
  • packages/cli-v3/src/config.ts
  • packages/cli-v3/templates/examples/schedule.mjs.template
  • packages/cli-v3/templates/examples/schedule.ts.template
  • packages/cli-v3/templates/examples/simple.mjs.template
  • packages/cli-v3/templates/examples/simple.ts.template
  • packages/cli-v3/templates/trigger.config.mjs.template
  • packages/cli-v3/templates/trigger.config.ts.template
  • packages/core/src/v3/config.ts
  • packages/core/src/v3/errors.ts
  • packages/core/src/v3/links.ts
  • packages/core/src/v3/types/tasks.ts
  • packages/trigger-sdk/src/v3/config.test.ts
  • packages/trigger-sdk/src/v3/config.ts
  • packages/trigger-sdk/src/v3/maxComputeSeconds.test.ts
  • packages/trigger-sdk/src/v3/maxComputeSeconds.ts
  • packages/trigger-sdk/src/v3/shared.ts

Walkthrough

The change adds maxComputeSeconds to task and trigger configuration. Deprecated maxDuration remains supported as a fallback. maxComputeSeconds takes precedence when both values exist. CLI and SDK configuration normalize the value to internal maxDuration. Shared trigger, batch, streaming, and task registration paths use the same resolver. Templates, errors, documentation links, tests, and release notes are updated.

✨ 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.

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.

1 participant