← back

Trigger.dev: How Background Jobs Actually Work

Dec 6, 2025

trigger.devbackground-jobsserverlesstypescript

Trigger.dev is an open-source platform for building AI workflows and background jobs in TypeScript. The interesting part isn’t what it does—it’s how it achieves “no timeouts” in a serverless-like environment.

The Problem with Serverless

AWS Lambda, Vercel, and similar platforms impose hard timeout limits (typically 10-15 minutes max). If your task takes longer—processing a video, running an AI chain, sending a multi-day email campaign—you’re stuck breaking it into awkward chunks or moving to traditional servers.

Trigger.dev v2 had the same problem. Code ran in your existing deployment, so “long-running” was a lie. You could only go long if you split work into many short tasks, each under the serverless timeout.

The Solution: CRIU Checkpoint-Resume

Trigger.dev v3 solves this with CRIU (Checkpoint/Restore In Userspace), pronounced “kree-oo.”

Here’s the flow:

  1. Task starts in an isolated execution environment
  2. Task needs to wait (for a subtask, a delay, human approval)
  3. CRIU checkpoints the entire process - memory, CPU registers, open file descriptors, everything
  4. Resources are released - the execution environment is freed
  5. Later, task resumes - checkpoint is restored to a new environment, execution continues exactly where it left off

The task thinks it never stopped. From the code’s perspective, await wait.for({ hours: 24 }) just… waits. Under the hood, your process was frozen, stored, and resurrected a day later on potentially different hardware.

What This Enables

import { task, wait } from "@trigger.dev/sdk";

export const longWorkflow = task({
  id: "long-workflow",
  run: async (payload) => {
    // This can literally run for days
    await processStep1();
    await wait.for({ hours: 6 });
    await processStep2();

    // Wait for human approval
    const approval = await wait.forApproval();
    if (!approval) return;

    await finalStep();
  },
});

No timeout management. No breaking things into separate jobs. No state serialization headaches. The checkpoint captures everything automatically.

The Trade-offs

Current State (2025)

The checkpoint-resume pattern is a clever solution that preserves the serverless developer experience (no infra management, auto-scaling) while eliminating the timeout constraint that makes serverless unsuitable for many real workloads.

Source: trigger.dev