Timeouts

Limit how long a task can run for before it is automatically cancelled.
Task timeouts allow you to limit the amount of time that a task will run before it is automatically cancelled. This can be useful to prevent "run-away" tasks from consuming excessive resources.
By default, all standard-runtime tasks time out after 1 hour, but this can be extended up to a maximum of 12 hours. The workflow runtime allows runs to execute for much longer—up to 60 days—but it does not yet support configuring a lower timeout.

Manual cancellation

In addition to timeouts, runs can be explicitly cancelled to stop it from completing:

Cancellation behavior

When a run times out or is manually cancelled, it will be issued a SIGTERM and given 10 seconds to gracefully shut down. If the run has not yet exited after 10 seconds, then the run will be sent a SIGKILL.
An example run that has been cancelled.
An example run that has been cancelled.
Tasks can gracefully handle cancellation by listening for SIGTERM signals and performing any relevant cleanup before exiting on their own.
In the case where a run is cancelled before it is started, the run will be immediately marked as cancelled and the behavior above will not apply.

Timeout configuration

Timeouts are represented in seconds since a task was started.
typescript
Copied
1
export default airplane.task(
2
{
3
slug: "my_task",
4
timeout: 600,
5
},
6
async () => {...}
7
);