Everytime a Job is triggered, a Run is created with a payload of data.
Anatomy of a Run
A Run is a record of the execution of a Job. It is created fromrun()
function of a Job.
- The
run()
function is called with some useful parameters. More on that in a second. - Inside the run function you can write regular code and use Tasks.
- You can return data, which will then be retrievable with getRun or the React hooks.
Resumability
Runs can exceed the maximum timeout on serverless platforms. If a Run exceeds this limit, it will be re-run. When it is re-run, any completed Tasks return their original output and they aren’t re-run. Read more about Resumability.Run function parameters
payload
The payload is the data that triggered the Job. It is the same data that was sent to the Trigger that triggered the Job.- For Webhooks the payload is the data from the webhook.
- For Events the payload is the data from the event, in the example above that’s
{ url: "https://..." }
. - For Scheduled the payload is an object with the timestamp and the last timestamp (previous run).
io
Theio
object gives you access to Integrations and other useful functions. View the full reference for io
.
A few things you can do with io
:
- Use Integrations.
- Add delays (that can be longer than your server timeout).
- Log messages to the Run log.
- Perform background fetch requests (that can be longer than your server timeout).
- Send events to Trigger other Jobs.
- Create a Task manually by wrapping code in
io.runTask
.
context
Thecontext
object gives you access to information about the current Run, Job, Environment, Organization and Event. View the full reference for context
.
Run Statuses
Pending
The run has been created but has not started yet. This is the initial status of a run.Queued
The run is waiting to be executed. Runs can be queued because of Run Execution Concurrency LimitsWaiting on Connections
If a run depends on a hosted integration, it will be in this status until the integration is ready.Executing
The run is currently executing. This means that the run function is running.Waiting
The run is waiting, either because of a call toio.wait()
or because a task failed and will be retried at some point in the future. Runs in this state don’t count towards concurrency limits.