You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/realtime/overview.mdx
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Trigger.dev Realtime is a set of APIs that allow you to subscribe to runs and ge
8
8
9
9
## How it works
10
10
11
-
The Realtime API is built on top of [Electric SQL](https://electric-sql.com/), an open-source PostgreSQL syncing engine. The Trigger.dev API wraps Electric SQL and provides a simple API to subscribe to runs and get real-time updates.
11
+
The Realtime API is built on top of [Electric SQL](https://electric-sql.com/), an open-source PostgreSQL syncing engine. The Trigger.dev API wraps Electric SQL and provides a simple API to subscribe to [runs](/runs) and get real-time updates.
Copy file name to clipboardExpand all lines: docs/runs.mdx
+45-18Lines changed: 45 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
-
title: "Runs & attempts"
3
-
description: "Understanding the lifecycle of task execution in Trigger.dev"
2
+
title: "Runs"
3
+
description: "Understanding the lifecycle of task run execution in Trigger.dev"
4
4
---
5
5
6
6
In Trigger.dev, the concepts of runs and attempts are fundamental to understanding how tasks are executed and managed. This article explains these concepts in detail and provides insights into the various states a run can go through during its lifecycle.
@@ -24,37 +24,52 @@ Runs can also find themselves in lots of other states depending on what's happen
24
24
25
25
### Initial States
26
26
27
-
<Iconicon="rectangle-history"iconType="solid"color="#FBBF24"size={17} /> **Waiting for deploy**: If a task is triggered before it has been deployed, the run enters this state and waits for the task to be deployed.
27
+
<Iconicon="rectangle-history"iconType="solid"color="#FBBF24"size={17} /> **Waiting for deploy**:
28
+
If a task is triggered before it has been deployed, the run enters this state and waits for the task
29
+
to be deployed.
28
30
29
-
<Iconicon="clock"iconType="solid"color="#878C99"size={17} /> **Delayed**: When a run is triggered with a delay, it enters this state until the specified delay period has passed.
31
+
<Iconicon="clock"iconType="solid"color="#878C99"size={17} /> **Delayed**: When a run is triggered
32
+
with a delay, it enters this state until the specified delay period has passed.
30
33
31
-
<Iconicon="rectangle-history"iconType="solid"color="#878C99"size={17} /> **Queued**: The run is ready to be executed and is waiting in the queue.
34
+
<Iconicon="rectangle-history"iconType="solid"color="#878C99"size={17} /> **Queued**: The run is ready
35
+
to be executed and is waiting in the queue.
32
36
33
37
### Execution States
34
38
35
-
<Iconicon="spinner-third"iconType="duotone"color="#3B82F6"size={17} /> **Executing**: The task is currently running.
39
+
<Iconicon="spinner-third"iconType="duotone"color="#3B82F6"size={17} /> **Executing**: The task is
40
+
currently running.
36
41
37
-
<Iconicon="arrows-rotate"iconType="solid"color="#3B82F6"size={17} /> **Reattempting**: The task has failed and is being retried.
42
+
<Iconicon="arrows-rotate"iconType="solid"color="#3B82F6"size={17} /> **Reattempting**: The task has
43
+
failed and is being retried.
38
44
39
-
<Iconicon="snowflake"iconType="solid"color="#68BAF2"size={17} /> **Frozen**: Task has been frozen and is waiting to be resumed.
45
+
<Iconicon="snowflake"iconType="solid"color="#68BAF2"size={17} /> **Frozen**: Task has been frozen
46
+
and is waiting to be resumed.
40
47
41
48
### Final States
42
49
43
-
<Iconicon="circle-check"iconType="solid"color="#28BF5C"size={17} /> **Completed**: The task has successfully finished execution.
50
+
<Iconicon="circle-check"iconType="solid"color="#28BF5C"size={17} /> **Completed**: The task has successfully
51
+
finished execution.
44
52
45
-
<Iconicon="ban"iconType="solid"color="#878C99"size={17} /> **Canceled**: The run was manually canceled by the user.
53
+
<Iconicon="ban"iconType="solid"color="#878C99"size={17} /> **Canceled**: The run was manually canceled
54
+
by the user.
46
55
47
-
<Iconicon="circle-xmark"iconType="solid"color="#E11D48"size={17} /> **Failed**: The task has failed to complete successfully.
56
+
<Iconicon="circle-xmark"iconType="solid"color="#E11D48"size={17} /> **Failed**: The task has failed
57
+
to complete successfully.
48
58
49
-
<Iconicon="alarm-exclamation"iconType="solid"color="#E11D48"size={17} /> **Timed out**: Task has failed because it exceeded its `maxDuration`.
59
+
<Iconicon="alarm-exclamation"iconType="solid"color="#E11D48"size={17} /> **Timed out**: Task has
60
+
failed because it exceeded its `maxDuration`.
50
61
51
-
<Iconicon="fire"iconType="solid"color="#E11D48"size={17} /> **Crashed**: The worker process crashed during execution (likely due to an Out of Memory error).
62
+
<Iconicon="fire"iconType="solid"color="#E11D48"size={17} /> **Crashed**: The worker process crashed
63
+
during execution (likely due to an Out of Memory error).
52
64
53
-
<Iconicon="bolt-slash"iconType="solid"color="#E11D48"size={17} /> **Interrupted**: In development mode, when the CLI is disconnected.
65
+
<Iconicon="bolt-slash"iconType="solid"color="#E11D48"size={17} /> **Interrupted**: In development
66
+
mode, when the CLI is disconnected.
54
67
55
-
<Iconicon="bug"iconType="solid"color="#E11D48"size={17} /> **System failure**: An unrecoverable system error has occurred.
68
+
<Iconicon="bug"iconType="solid"color="#E11D48"size={17} /> **System failure**: An unrecoverable system
69
+
error has occurred.
56
70
57
-
<Iconicon="trash-can"iconType="solid"color="#878C99"size={17} /> **Expired**: The run's Time-to-Live (TTL) has passed before it could start executing.
71
+
<Iconicon="trash-can"iconType="solid"color="#878C99"size={17} /> **Expired**: The run's Time-to-Live
72
+
(TTL) has passed before it could start executing.
58
73
59
74
## Attempts
60
75
@@ -150,13 +165,13 @@ You can also replay runs from the dashboard using the same or different payload.
150
165
151
166
The `triggerAndWait()` function triggers a task and then lets you wait for the result before continuing. [Learn more about triggerAndWait()](/triggering#yourtask-triggerandwait).
152
167
153
-
.png)
168
+
.png>)
154
169
155
170
#### batchTriggerAndWait()
156
171
157
172
Similar to `triggerAndWait()`, the `batchTriggerAndWait()` function lets you batch trigger a task and wait for all the results [Learn more about batchTriggerAndWait()](/triggering#yourtask-batchtriggerandwait).
158
173
159
-
.png)
174
+
.png>)
160
175
161
176
### Runs API
162
177
@@ -181,6 +196,18 @@ runs.cancel(runId);
181
196
182
197
These methods allow you to access detailed information about runs and their attempts, including payloads, outputs, parent runs, and child runs.
183
198
199
+
### Real-time updates
200
+
201
+
You can subscribe to run updates in real-time using the `subscribeToRun()` function:
202
+
203
+
```ts
204
+
forawait (const run ofruns.subscribeToRun(runId)) {
205
+
console.log(run);
206
+
}
207
+
```
208
+
209
+
For more on real-time updates, see the [Realtime](/realtime) documentation.
210
+
184
211
### Triggering runs for undeployed tasks
185
212
186
213
It's possible to trigger a run for a task that hasn't been deployed yet. The run will enter the "Waiting for deploy" state until the task is deployed. Once deployed, the run will be queued and executed normally.
0 commit comments