Skip to main content
Each Trigger.dev task run executes inside an isolated container. The machine option controls how much compute that container is allocated. Higher-spec machines increase cost but improve performance for CPU-bound or memory-intensive tasks.

Setting a machine for a task

Pass the machine option when defining a task:
/trigger/heavy-task.ts

Setting the default machine

You can set a project-wide default machine in trigger.config.ts. All tasks without an explicit machine option will use this default.
trigger.config.ts
If you don’t set a default, tasks use small-1x (0.5 vCPU, 0.5 GB RAM).

Machine presets

View pricing for each preset on the Trigger.dev pricing page.

Overriding the machine at trigger time

You can override the machine when triggering a task — useful when the required resources depend on the payload (e.g. a large file upload or a high-data customer):

Out of memory (OOM) errors

When a task run is killed due to exceeding the machine’s memory limit, you’ll see an error like:
Trigger.dev automatically detects the following OOM conditions:
  • The Node.js V8 heap limit is exceeded
  • The entire container process exceeds the machine’s memory limit
  • A child process (e.g. ffmpeg) exceeds the memory limit and exits with a non-zero code

Retrying with a larger machine

For tasks that only occasionally hit memory limits, you can configure an automatic retry on OOM with a larger machine:
/trigger/heavy-task.ts
OOM retry only triggers on out-of-memory errors. It does not permanently change the machine for new runs — if you consistently see OOM errors, increase the machine property directly.

Throwing an explicit OOM error

If your code detects it is about to run out of memory (for example, a native library signals an allocation failure), you can throw OutOfMemoryError to trigger the same OOM handling:
/trigger/heavy-task.ts

Monitoring memory usage

To diagnose OOM errors, add the ResourceMonitor helper to your project. It logs memory, CPU, and disk usage at a regular interval:
/trigger/tasks.ts
To also monitor child process memory (e.g. an ffmpeg subprocess):
The ResourceMonitor is a helper class you add to your own project. Copy the implementation from the Trigger.dev examples repository or write a simplified version using Node.js process.memoryUsage().
/src/resourceMonitor.ts