Using the Trigger.dev v3 realtime API
runs.subscribeToRun
function. This function returns an async iterator that you can use to get updates on the run status.
runs.subscribeToRunsWithTag
function.
batchTrigger
to trigger multiple runs, you can also subscribe to changes to all the runs triggered in the batch using the runs.subscribeToBatch
function.
runs.retrieve
function. This is because Electric SQL streams changes from a single PostgreSQL table, and the run object returned by runs.retrieve
is a combination of multiple tables.
The run object returned by the async iterator has the following fields:
RunStatus enum
Status | Description |
---|---|
WAITING_FOR_DEPLOY | Task hasn’t been deployed yet but is waiting to be executed |
QUEUED | Run is waiting to be executed by a worker |
EXECUTING | Run is currently being executed by a worker |
REATTEMPTING | Run has failed and is waiting to be retried |
FROZEN | Run has been paused by the system, and will be resumed by the system |
COMPLETED | Run has been completed successfully |
CANCELED | Run has been canceled by the user |
FAILED | Run has been completed with errors |
CRASHED | Run has crashed and won’t be retried, most likely the worker ran out of resources, e.g. memory or storage |
INTERRUPTED | Run was interrupted during execution, mostly this happens in development environments |
SYSTEM_FAILURE | Run has failed to complete, due to an error in the system |
DELAYED | Run has been scheduled to run at a specific time |
EXPIRED | Run has expired and won’t be executed |
TIMED_OUT | Run has reached it’s maxDuration and has been stopped |
subscribeToRun
function. This will give you type-safe access to the run’s payload and output.
subscribeToRunsWithTag
, you can pass a union of task types for all the possible tasks that can have the tag.