-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(sdk): replace maxDuration with maxComputeSeconds (user-facing rename) #4436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
deepshekhardas
wants to merge
1
commit into
triggerdotdev:main
from
deepshekhardas:fix/max-compute-seconds
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@trigger.dev/core": patch | ||
| "@trigger.dev/sdk": patch | ||
| "trigger.dev": patch | ||
| --- | ||
|
|
||
| Add `maxComputeSeconds` as the user-facing replacement for `maxDuration` on `defineConfig`, task definitions, and trigger options. The new name makes the unit (compute-time seconds) unambiguous at the call site. `maxDuration` is JSDoc-deprecated and still accepted; if both are set, `maxComputeSeconds` wins. The `init` templates have been updated to use the new name. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { describe, it, expect } from "vitest"; | ||
| import { defineConfig } from "./config.js"; | ||
|
|
||
| describe("defineConfig - maxComputeSeconds", () => { | ||
| it("uses maxComputeSeconds when only maxComputeSeconds is set", () => { | ||
| const cfg = defineConfig({ project: "p", maxComputeSeconds: 600 }); | ||
| expect(cfg.maxDuration).toBe(600); | ||
| }); | ||
|
|
||
| it("uses maxDuration when only maxDuration is set", () => { | ||
| const cfg = defineConfig({ project: "p", maxDuration: 600 }); | ||
| expect(cfg.maxDuration).toBe(600); | ||
| }); | ||
|
|
||
| it("prefers maxComputeSeconds when both are set", () => { | ||
| const cfg = defineConfig({ project: "p", maxComputeSeconds: 600, maxDuration: 9999 }); | ||
| expect(cfg.maxDuration).toBe(600); | ||
| }); | ||
|
|
||
| it("leaves maxDuration unset when neither is provided", () => { | ||
| const cfg = defineConfig({ project: "p" }); | ||
| expect(cfg.maxDuration).toBeUndefined(); | ||
| }); | ||
|
|
||
| it("strips maxComputeSeconds from the returned config", () => { | ||
| const cfg = defineConfig({ project: "p", maxComputeSeconds: 600 }); | ||
| expect((cfg as { maxComputeSeconds?: number }).maxComputeSeconds).toBeUndefined(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { describe, it, expect } from "vitest"; | ||
| import { resolveMaxComputeSeconds } from "./maxComputeSeconds.js"; | ||
|
|
||
| describe("resolveMaxComputeSeconds", () => { | ||
| it("returns maxComputeSeconds when only maxComputeSeconds is set", () => { | ||
| expect(resolveMaxComputeSeconds({ maxComputeSeconds: 300 })).toBe(300); | ||
| }); | ||
|
|
||
| it("returns maxDuration when only maxDuration is set", () => { | ||
| expect(resolveMaxComputeSeconds({ maxDuration: 300 })).toBe(300); | ||
| }); | ||
|
|
||
| it("prefers maxComputeSeconds when both are set", () => { | ||
| expect(resolveMaxComputeSeconds({ maxComputeSeconds: 300, maxDuration: 999 })).toBe(300); | ||
| }); | ||
|
|
||
| it("returns undefined when neither is set", () => { | ||
| expect(resolveMaxComputeSeconds({})).toBeUndefined(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| /** | ||
| * Collapse the user-facing `maxComputeSeconds` (new name) and `maxDuration` (deprecated) | ||
| * into a single value. If both are provided, `maxComputeSeconds` wins. | ||
| * | ||
| * Internal SDK/CLI/platform code only reads `maxDuration`, so all call sites that | ||
| * accept user input should funnel through this helper before forwarding the value. | ||
| */ | ||
| export function resolveMaxComputeSeconds(input: { | ||
| maxComputeSeconds?: number; | ||
| maxDuration?: number; | ||
| }): number | undefined { | ||
| return input.maxComputeSeconds ?? input.maxDuration; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 = resolvedMaxDurationatpackages/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
validateConfigruns only inside the CLI process (packages/cli-v3/src/config.ts:196). The index workers re-import the user's built config module directly (importConfigatpackages/cli-v3/src/entryPoints/dev-index-worker.ts:75-86, same inpackages/cli-v3/src/entryPoints/managed-index-worker.ts) and then apply the project default withif (typeof config.maxDuration === "number")(packages/cli-v3/src/entryPoints/dev-index-worker.ts:147-152). For a config exported throughdefineConfig()the resolution happens at import time in the SDK, so it works; for a plain-object export — exactly the case the new comment atpackages/cli-v3/src/config.ts:362-364claims to support — the worker sees onlymaxComputeSeconds,maxDurationis undefined, and no per-task default is applied.Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.