Understanding the lifecycle of task run execution in Trigger.dev
yourTask.trigger({ foo: "bar" })
). It represents a single instance of a task being executed and contains the following key information:
maxDuration
.
Crashed: The worker process crashed
during execution (likely due to an Out of Memory error) and won’t be retried.
System failure: An unrecoverable system
error has occurred.
Expired: The run’s Time-to-Live
(TTL) has passed before it could start executing.
isQueued
: Returns true
when the status is QUEUED
, PENDING_VERSION
, or DELAYED
isExecuting
: Returns true
when the status is EXECUTING
or DEQUEUED
. These count against your concurrency limits.isWaiting
: Returns true
when the status is WAITING
. These do not count against your concurrency limits.isCompleted
: Returns true
when the status is any of the completed statusesisCanceled
: Returns true
when the status is CANCELED
isFailed
: Returns true
when the status is any of the failed statusesisSuccess
: Returns true
when the status is COMPLETED
Expired
. This is useful for time-sensitive tasks where immediate execution is important. For example, when you queue many runs simultaneously and exceed your concurrency limits, some runs might be delayed - using TTL ensures they only execute if they can start within your specified timeframe.
Note that dev runs automatically have a 10-minute TTL. In Staging and Production environments, no TTL is set by default.
triggerAndWait()
function triggers a task and then lets you wait for the result before continuing. Learn more about triggerAndWait().
triggerAndWait()
, the batchTriggerAndWait()
function lets you batch trigger a task and wait for all the results Learn more about batchTriggerAndWait().
list()
function to narrow down the results:
run.payload
and run.output
:
retrieve()
and the response will already be typed:
runs.retrieve()
, you can provide the type of the task to correctly type the run.payload
and run.output
: