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/migrating-from-v3.mdx
+13-48Lines changed: 13 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,19 +8,19 @@ import MigrateV4UsingAi from "/snippets/migrate-v4-using-ai.mdx";
8
8
9
9
## What's new in v4?
10
10
11
-
| Feature | Description |
12
-
|:--------|:------------|
13
-
|[Wait for token](/wait-for-token)| Create and wait for tokens to be completed, enabling approval workflows and waiting for arbitrary external conditions. |
14
-
| Wait idempotency | Skip waits if the same idempotency key is used again when using [wait for](/wait-for#wait-idempotency), [wait until](/wait-until#wait-idempotency), or [wait for token](/wait-for-token#wait-idempotency). |
15
-
|[Priority](/runs/priority)| Specify a priority when triggering a task. |
16
-
|[Global lifecycle hooks](/tasks/overview#global-lifecycle-hooks)| Register global lifecycle hooks that are executed for all runs, regardless of the task. |
17
-
|[onWait and onResume](/tasks/overview#onwait-and-onresume-functions)| Run code when a run is paused or resumed because of a wait. |
18
-
|[onComplete](/tasks/overview#oncomplete-function)| Run code when a run completes, regardless of whether it succeeded or failed. |
19
-
|[onCancel](/tasks/overview#oncancel-function)| Run code when a run is cancelled. |
20
-
|[Hidden tasks](/hidden-tasks)| Create tasks that are not exported from your trigger files but can still be executed. |
21
-
|[Middleware & locals](#middleware-and-locals)| The middleware system runs at the top level, executing before and after all lifecycle hooks. The locals API allows sharing data between middleware and hooks. |
22
-
|[useWaitToken](/frontend/react-hooks/use-wait-token)| Use the useWaitToken hook to complete a wait token from a React component. |
23
-
|[ai.tool](/tasks/schemaTask#ai-tool)| Create an AI tool from an existing `schemaTask` to use with the Vercel [AI SDK](https://vercel.com/docs/ai-sdk). |
|[Wait for token](/wait-for-token)| Create and wait for tokens to be completed, enabling approval workflows and waiting for arbitrary external conditions.|
14
+
| Wait idempotency | Skip waits if the same idempotency key is used again when using [wait for](/wait-for#wait-idempotency), [wait until](/wait-until#wait-idempotency), or [wait for token](/wait-for-token#wait-idempotency). |
15
+
|[Priority](/runs/priority)| Specify a priority when triggering a task.|
16
+
|[Global lifecycle hooks](/tasks/overview#global-lifecycle-hooks)| Register global lifecycle hooks that are executed for all runs, regardless of the task.|
17
+
|[onWait and onResume](/tasks/overview#onwait-and-onresume-functions)| Run code when a run is paused or resumed because of a wait. |
18
+
|[onComplete](/tasks/overview#oncomplete-function)| Run code when a run completes, regardless of whether it succeeded or failed.|
19
+
|[onCancel](/tasks/overview#oncancel-function)| Run code when a run is cancelled.|
20
+
|[Hidden tasks](/hidden-tasks)| Create tasks that are not exported from your trigger files but can still be executed.|
21
+
|[Middleware & locals](#middleware-and-locals)| The middleware system runs at the top level, executing before and after all lifecycle hooks. The locals API allows sharing data between middleware and hooks.|
22
+
|[useWaitToken](/frontend/react-hooks/use-wait-token)| Use the useWaitToken hook to complete a wait token from a React component.|
23
+
|[ai.tool](/tasks/schemaTask#ai-tool)| Create an AI tool from an existing `schemaTask` to use with the Vercel [AI SDK](https://vercel.com/docs/ai-sdk).|
24
24
25
25
## Node.js support
26
26
@@ -210,41 +210,6 @@ await myTask.trigger({ foo: "bar" }); // Will use the queue defined on the task
210
210
awaitmyTask2.trigger({ foo: "bar" }); // Will use the queue defined on the task
211
211
```
212
212
213
-
### Releasing concurrency on waits
214
-
215
-
We've changed the default behavior on how concurrency is released when a run is paused or resumed because of a wait. Previously, the concurrency would be released immediately when the run was first paused, no matter the settings on the queue.
216
-
217
-
Now we will no longer release concurrency on a queue that has a specified `concurrencyLimit` when a run is paused. You can go back to the previous behavior by setting the `releaseConcurrencyOnWaitpoint` option to `true` on the queue:
218
-
219
-
```ts
220
-
const myQueue =queue({
221
-
name: "my-queue",
222
-
concurrencyLimit: 10,
223
-
releaseConcurrencyOnWaitpoint: true,
224
-
});
225
-
```
226
-
227
-
You can also now control whether concurrency is released when performing a wait:
228
-
229
-
```ts
230
-
// This will prevent the run from being released back into the queue when the wait starts
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.
235
-
236
-
<Note>
237
-
If you do choose to release concurrency on waits, be aware that it's possible a resume is delayed
238
-
if the concurrency that was released is not available at the time the wait completes. In this
239
-
case, the run will go back into the queue and will resume once concurrency becomes available.
240
-
</Note>
241
-
242
-
This new behavior effects all the wait functions:
243
-
244
-
- Wait for duration (e.g. `wait.for({ seconds: 10 })`)
245
-
- Wait for a child task to complete (e.g. `myTask.triggerAndWait()`, `myTask.batchTriggerAndWait([...])`)
246
-
- Wait for a token to complete (e.g. `wait.forToken(tokenId)`)
247
-
248
213
### Lifecycle hooks
249
214
250
215
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