What’s new in v4, how to migrate, and breaking changes.
Feature | Description |
---|---|
Wait for token | Create and wait for tokens to be completed, enabling approval workflows and waiting for arbitrary external conditions. |
Wait idempotency | Skip waits if the same idempotency key is used again when using wait for, wait until, or wait for token. |
Priority | Specify a priority when triggering a task. |
Global lifecycle hooks | Register global lifecycle hooks that are executed for all runs, regardless of the task. |
onWait and onResume | Run code when a run is paused or resumed because of a wait. |
onComplete | Run code when a run completes, regardless of whether it succeeded or failed. |
onCancel | Run code when a run is cancelled. |
Hidden tasks | Create tasks that are not exported from your trigger files but can still be executed. |
Middleware & 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. |
useWaitToken | Use the useWaitToken hook to complete a wait token from a React component. |
ai.tool | Create an AI tool from an existing schemaTask to use with the Vercel AI SDK. |
21.7.3
21.7.3
(default)22.16.0
(node-22
)1.2.20
(bun
)runtime
field in your trigger.config.ts
file.
trigger dev
CLI command and test your tasks locally, fixing any breaking changes.Copy paste this prompt in full
@trigger.dev/*
packages to a 4.x
version.
@trigger.dev/sdk/v3
import path and moved to a new path:
handleError
and init
handleError
hook to catchError
to better reflect that it can catch and react to errors. handleError
will be removed in a future version.
init
was previously used to initialize data used in the run function:
locals
API and middleware. See the Improved middleware and locals section for more details.
toolTask
function, which created both a Trigger.dev task and a tool compatible with the Vercel AI SDK:
toolTask
function with the ai.tool
function, which creates an AI tool from an existing schemaTask
. See the ai.tool page for more details.
queue
function:
concurrencyKey
you can specify the queue
and concurrencyKey
like this:
concurrencyKey
, a new queue will be created using the concurrencyLimit
from the queue. This allows you to have a queue per user.
ctx
object:
ctx.attempt.id
and ctx.attempt.status
have been removed. ctx.attempt.number
is still available.ctx.task.exportName
has been removed (since we no longer require tasks to be exported to be triggered).batchTrigger
function no longer returns a runs
list directly. In v3, you could access the runs directly from the batch handle:
runs.list()
method to get the list of runs:
Package | Previous Version | New Version | Change Type |
---|---|---|---|
@opentelemetry/api-logs | 0.52.1 | 0.203.0 | Major update |
@opentelemetry/exporter-logs-otlp-http | 0.52.1 | 0.203.0 | Major update |
@opentelemetry/exporter-trace-otlp-http | 0.52.1 | 0.203.0 | Major update |
@opentelemetry/instrumentation | 0.52.1 | 0.203.0 | Major update |