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
Updates the trigger, batchTrigger and their *AndWait variants to use the first parameter for the payload/items, and the second parameter for options (#1045)
Also always returns a `TaskRunResult` object from `triggerAndWait` instead of rethrowing subtask errors in the parent
Updates the `trigger`, `batchTrigger` and their `*AndWait` variants to use the first parameter for the payload/items, and the second parameter for options.
We've also changed the API of the `triggerAndWait` result. Before, if the subtask that was triggered finished with an error, we would automatically "rethrow" the error in the parent task.
29
+
30
+
Now instead we're returning a `TaskRunResult` object that allows you to discriminate between successful and failed runs in the subtask:
31
+
32
+
Before:
33
+
34
+
```ts
35
+
try {
36
+
const result =awaityourTask.triggerAndWait({ foo: "bar" });
37
+
38
+
// result is the output of your task
39
+
console.log("result", result);
40
+
41
+
} catch (error) {
42
+
// handle subtask errors here
43
+
}
44
+
```
45
+
46
+
After:
47
+
48
+
```ts
49
+
const result =awaityourTask.triggerAndWait({ foo: "bar" });
50
+
51
+
if (result.ok) {
52
+
console.log(`Run ${result.id} succeeded with output`, result.output);
53
+
} else {
54
+
console.log(`Run ${result.id} failed with error`, result.error);
Copy file name to clipboardExpand all lines: docs/v3/migration-defer.mdx
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -71,15 +71,15 @@ export async function runLongRunningTask() {
71
71
}
72
72
```
73
73
74
-
In Trigger.dev your logic goes in the `run` function of a task. You can then `trigger` and `batchTrigger` that task, with a payload and options.
74
+
In Trigger.dev your logic goes in the `run` function of a task. You can then `trigger` and `batchTrigger` that task, with a payload as the first argument.
0 commit comments