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
const result =awaitwait.forToken<ApprovalToken>(tokenId);
41
45
42
46
if (result.ok) {
43
-
console.log("Token completed", result.output);
47
+
console.log("Token completed", result.output.status); // "approved" or "rejected"
44
48
} else {
45
49
console.log("Token timed out", result.error);
46
50
}
@@ -51,7 +55,7 @@ if (result.ok) {
51
55
You can now pass an idempotency key to any wait function, allowing you to skip waits if the same idempotency key is used again. This can be useful if you want to skip waits when retrying a task, for example:
52
56
53
57
```ts
54
-
// Specify the idempotency key and TTL when creating a the token
58
+
// Specify the idempotency key and TTL when creating a wait token
55
59
const token =awaitwait.createToken({
56
60
idempotencyKey: "my-idempotency-key",
57
61
idempotencyKeyTTL: "1h",
@@ -80,7 +84,7 @@ You can now specify a priority when triggering a task. This allows you to priori
The priority value is a time duration in seconds, which offsets the timestamp of the run in the queue. If you specify a priority of `10`, the run will have over runs with a priority of `0` that were triggered within the last 10 seconds. A more concrete example:
87
+
The priority value is a time duration in seconds, which offsets the timestamp of the run in the queue. If you specify a priority of `10`, the run will win over runs with a priority of `0` that were triggered within the last 10 seconds. A more concrete example:
84
88
85
89
```ts
86
90
// Triggered at 12:00:00, into a queue with a large number of queued runs
@@ -93,7 +97,7 @@ In this case, the second run will be executed first, because it's priority moved
93
97
94
98
<Note>
95
99
We purposefully chose to use a time duration as the priority value instead of specifying priority
96
-
levels, because priority levels can cause "level starvation" where lower priortity runs are never
100
+
levels, because priority levels can cause "level starvation" where lower priority runs are never
97
101
executed because there are always higher priority runs in the queue.
98
102
</Note>
99
103
@@ -440,38 +444,38 @@ See the [AI SDK tool execution options docs](https://sdk.vercel.ai/docs/ai-sdk-c
440
444
441
445
## Installation
442
446
443
-
To opt-in to using v4, you will need to update your dependencies to the latest version of the `v4` tag.
447
+
To opt-in to using v4, you will need to update your dependencies to the latest version of the `v4-beta` tag.
444
448
445
449
<CodeGroup>
446
450
447
451
```bash npm
448
-
npm add @trigger.dev/sdk@v4
452
+
npm add @trigger.dev/sdk@v4-beta
449
453
```
450
454
451
455
```bash yarn
452
-
yarn add @trigger.dev/sdk@v4
456
+
yarn add @trigger.dev/sdk@v4-beta
453
457
```
454
458
455
459
```bash pnpm
456
-
pnpm add @trigger.dev/sdk@v4
460
+
pnpm add @trigger.dev/sdk@v4-beta
457
461
```
458
462
459
463
</CodeGroup>
460
464
461
-
You'll also need to use the `v4` version of the `trigger.dev` CLI package:
465
+
You'll also need to use the `v4-beta` version of the `trigger.dev` CLI package:
462
466
463
467
<CodeGroup>
464
468
465
469
```bash npx
466
-
npx trigger.dev@v4 dev
470
+
npx trigger.dev@v4-beta dev
467
471
```
468
472
469
473
```bash yarn
470
-
yarn dlx trigger.dev@v4 dev
474
+
yarn dlx trigger.dev@v4-beta dev
471
475
```
472
476
473
477
```bash pnpm
474
-
pnpm dlx trigger.dev@v4 dev
478
+
pnpm dlx trigger.dev@v4-beta dev
475
479
```
476
480
477
481
</CodeGroup>
@@ -481,7 +485,7 @@ Or you could install the CLI into your `devDependencies` and then use the `trigg
481
485
```json package.json
482
486
{
483
487
"devDependencies": {
484
-
"trigger.dev": "v4"
488
+
"trigger.dev": "v4-beta"
485
489
},
486
490
"scripts": {
487
491
"dev": "trigger dev"
@@ -644,14 +648,20 @@ You can also now control whether concurrency is released when performing a wait:
The new default behavior allows you to ensure that you can control the number of executing & waiting runs on a queue, and guarentee runs will resume once they are meant to be resumed.
651
+
The new default behavior allows you to ensure that you can control the number of executing & waiting runs on a queue, and guarantee runs will resume once they are meant to be resumed.
648
652
649
653
<Note>
650
654
If you do choose to release concurrency on waits, be aware that it's possible a resume is delayed
651
655
if the concurrency that was released is not available at the time the wait completes. In this
652
656
case, the run will go back into the queue and will resume once concurrency becomes available.
653
657
</Note>
654
658
659
+
This new behavior effects all the wait functions:
660
+
661
+
- Wait for duration (e.g. `wait.for({ seconds: 10 })`)
662
+
- Wait for a child task to complete (e.g. `myTask.triggerAndWait()`, `myTask.batchTriggerAndWait([...])`)
663
+
- Wait for a token to complete (e.g. `wait.forToken(tokenId)`)
664
+
655
665
### Lifecycle hooks
656
666
657
667
We've changed the function signatures of the lifecycle hooks to be more consistent and easier to use, by unifying all the parameters into a single object that can be destructured.
0 commit comments