# Durable beside Trigger.dev

The shape: a background-job platform. [Why Durable](https://durablesdk.com/why/vs/trigger-dev) steps this walk
beat by beat; this page is the walk in prose, with the page each beat
reads under Sources, and [Compared](https://durablesdk.com/docs/compare.md) is the table of every
product.

## What Trigger.dev gives, as its documentation describes

**A task on the platform's workers.** A task is an async function under an id. The CLI's deploy builds the code and packages it into an image per environment; a trigger runs it in an isolated environment on the platform's worker pool, and your app gets a handle back before the task finishes. [1]

**A retry runs the whole function again.** A thrown error fails the attempt and the next attempt runs the run function from the top, so every call inside it repeats unless you made it idempotent. A child task is triggered again too unless its trigger carries an idempotency key, and then the repeat returns the original child run. A key stops a task being triggered twice, scoped to the task and the environment and kept for a set window; a failed run clears its key, a successful or cancelled run keeps it. [2]

**Retries and a catch.** A task retries on a thrown error under a backoff you set; catchError can skip the retry or set the next attempt's time, and a task aborts its own retries by throwing an abort error. After a fix is deployed, failed runs are replayed in bulk from the dashboard or the SDK. [3]

**A wait snapshots the process.** On the platform's cloud a long wait pauses the run and frees its slot only once the machine is snapshotted and shut down; a shorter wait stays executing and holds its concurrency slot. [4]

**A token with no timeout.** A wait token is completed from your backend with the SDK, by a request to the token's URL or from a browser under a public access token; its timeout is optional, and a token without one never times out. [5]

**A dashboard of traces.** Logs are kept for the plan's retention period, and a query looks back no further than the plan allows. [6]

## The same work under Durable

**No image, no machine, no worker.** The engine is a library inside your own functions on the one Postgres the app already has; a minute cron is the one moving part outside the request path.

**The key is a field list.** `key: ["orderId", "requestId"]`. The key and the run commit in one transaction, so the same intent twice is one run for the row's life, and a key that reads the clock is refused before a deploy.

**A finished step is never re-run.** Each step's input and output land on a row before the body goes on; after a crash the next attempt replays the finished rows and re-invokes only what did not finish.

**The undo in reverse, then the images.** Every step carries its undo with its effect or says why it cannot, refused at the door otherwise; when a later step fails the undos run in reverse, each its own ledger row. Every write leaves a before and after image on an append-only, hash-chained ledger in your database; `durable-sdk ledger verify --file <export>` walks an export offline.

**The agent asks the graph.** `durable-sdk explain <workflow>` prints what the door admits, every step with its undo and its writes, the facts and who listens; `durable-sdk graph walk <subject>` prints the closure from any node; `durable-sdk graph impact --changed` prints what a change reaches before it is made. Offline, over a committed index: an AI coding agent asks before it edits, never guesses.

**Nothing to write but the steps.** No key per subtask, no snapshot, no compensation by hand, no record kept by hand; a failed run waits in limbo for a person with its rows.

## What you write yourself

| What you write yourself               | Trigger.dev                                                                                                                                                                                                                                                                                                                        | Durable                                                                              |
| ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| A task on the platform's workers      | The deploy per environment and the API key each environment carries.                                                                                                                                                                                                                                                               | none; the engine is a library inside your functions on your Postgres                 |
| A retry runs the whole function again | An idempotency key on every child trigger, and the provider's own key on every API call, write and email inside the run, or a record in your own database you check before each one. The key, its scope and its lifetime where the defaults do not fit, and the reset after a success or a cancel when the work must happen again. | a finished step is served from its row; a provider write reads before it writes      |
| Retries and a catch                   | The compensation when a later step fails, which the docs never describe, and the guard on every call a retry repeats.                                                                                                                                                                                                              | the undo declared on the step, run in reverse, each a ledger row; limbo for a person |
| A wait snapshots the process          | The length of each wait against the slot it holds, since a wait shorter than the snapshot point keeps its slot, and the idempotency key that stops a retried task waiting twice.                                                                                                                                                   | a parked run is rows; no slot held, no snapshot                                      |
| A token with no timeout               | The timeout on each token, and the branch for the timed-out result, since a timeout is the one error the wait returns.                                                                                                                                                                                                             | the workflow's own timeout bounds every wait                                         |
| A dashboard of traces                 | The images of your own data before and after a write, which no log or trace holds.                                                                                                                                                                                                                                                 | the ledger: before and after images, hash-chained, never pruned                      |

When Trigger.dev wins: long compute on a machine you size with no function deadline, a running process snapshotted through a wait, and live streams from a task to a page.

## Sources

1. https://trigger.dev/docs/how-it-works
2. https://trigger.dev/docs/idempotency
3. https://trigger.dev/docs/errors-retrying
4. https://trigger.dev/docs/wait-for
5. https://trigger.dev/docs/wait-for-token
6. https://trigger.dev/docs/limits

---

Prompt for an agent:

```text
Read https://durablesdk.com/docs/compare/trigger-dev.md, then decide between Durable and Trigger.dev for a keyed multi-step job that outlives a request; run durable-sdk doctor --host before and after; a refused line is a refusal id: durable-sdk explain <id>
```
