Skip to content

Commit 05058c5

Browse files
committed
docs: document ttl: 0 as opt-out for config-level and task-level TTL
1 parent b3cebee commit 05058c5

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

docs/config/config-file.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ export default defineConfig({
364364
});
365365
```
366366

367-
You can override this on a per-task basis by setting `ttl` on the task definition, or per-trigger by passing `ttl` in the trigger options. See [Time-to-live (TTL)](/runs#time-to-live-ttl) for more information.
367+
You can override this on a per-task basis by setting `ttl` on the task definition, or per-trigger by passing `ttl` in the trigger options. To opt a specific task out of the config-level TTL, set `ttl: 0` on the task. See [Time-to-live (TTL)](/runs#time-to-live-ttl) for more information.
368368

369369
## Process keep alive
370370

docs/runs.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,29 @@ export default defineConfig({
182182
});
183183
```
184184

185+
To opt out of a config-level or task-level TTL for a specific trigger, pass `ttl: 0`:
186+
187+
```ts
188+
// This run will not have a TTL, even if the task or config defines one
189+
await yourTask.trigger({ foo: "bar" }, { ttl: 0 });
190+
```
191+
192+
Similarly, to opt out of a config-level TTL for a specific task, set `ttl: 0` on the task definition:
193+
194+
```ts
195+
export const longRunningTask = task({
196+
id: "long-running-task",
197+
ttl: 0, // Opt out of the config-level TTL
198+
run: async (payload) => {
199+
//...
200+
},
201+
});
202+
```
203+
204+
<Note>
205+
Setting `ttl: 0` removes the config-level or task-level TTL, but the platform-level maximum still applies. See [Limits - Maximum run TTL](/limits#maximum-run-ttl) for details.
206+
</Note>
207+
185208
If the run hasn't started within the specified TTL, it will automatically expire, returning the status `Expired`. This is useful for time-sensitive tasks where immediate execution is important. For example, when you queue many runs simultaneously and exceed your concurrency limits, some runs might be delayed - using TTL ensures they only execute if they can start within your specified timeframe.
186209

187210
Dev runs automatically have a 10-minute TTL. On Trigger.dev Cloud, staging and production runs have a maximum TTL of 14 days applied automatically (runs without an explicit TTL get 14 days; longer TTLs are clamped). See [Limits — Maximum run TTL](/limits#maximum-run-ttl) for details.

docs/tasks/overview.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const timeSensitiveTask = task({
150150
});
151151
```
152152

153-
You can override this per-trigger by passing `ttl` in the trigger options, or set a project-wide default in your [trigger.config.ts](/config/config-file#ttl). See [Time-to-live (TTL)](/runs#time-to-live-ttl) for more information.
153+
You can override this per-trigger by passing `ttl` in the trigger options, or set a project-wide default in your [trigger.config.ts](/config/config-file#ttl). Set `ttl: 0` to opt out of a config-level TTL. See [Time-to-live (TTL)](/runs#time-to-live-ttl) for more information.
154154

155155
## Global lifecycle hooks
156156

0 commit comments

Comments
 (0)