Files
triggerdotdev--trigger.dev/docs/replaying.mdx
T
devin-ai-integration[bot] 4b28080ed4 feat: add isReplay to run context (#3454)
## Summary

Adds `isReplay` boolean to the run context (`ctx.run.isReplay`),
following the same pattern as the existing `isTest`. The value is
derived from the existing `replayedFromTaskRunFriendlyId` database
field, so no schema migration is needed.

##  Checklist

- [x] I have followed every step in the [contributing
guide](https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md)
- [x] The PR title follows the convention.
- [x] I ran and tested the code works

---

## Testing

- Verified `@trigger.dev/core` builds successfully
- Verified `webapp` typechecks successfully
- All new fields use `default(false)` for backwards compatibility

---

## Changelog

- Added `isReplay` to `TaskRun` and `V3TaskRun` schemas in `common.ts`
- Added `RUN_IS_REPLAY` semantic attribute and wired it in `taskContext`
- Propagated `isReplay` through the dequeue system, run attempt system,
and all execution context construction paths (V1 + V2)
- Added `isReplay` to `DequeuedMessage` and
`TaskRunExecutionLazyAttemptPayload` schemas
- Added patch changeset for `@trigger.dev/core`
- Updated docs: added `isReplay` to context reference, added "Detecting
replays" section to replaying page

---

💯

Link to Devin session:
https://app.devin.ai/sessions/1d6f1b3cc39a4623b72d05bf00f2d70c

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: nick <55853254+nicktrn@users.noreply.github.com>
2026-04-28 11:57:44 +02:00

72 lines
2.2 KiB
Plaintext

---
title: "Replaying"
description: "A replay is a copy of a run with the same payload but against the latest version in that environment. This is useful if something went wrong and you want to try again with the latest version of your code."
---
### Replaying from the UI
<Tabs>
<Tab title="From a run">
<Steps>
<Step title="Click the Replay button in the top right">
![Select a task, then in the bottom right
click "Replay"](/images/replay-run-action.png)
</Step>
<Step title="Confirm replay settings">
You can edit the payload <Icon icon="circle-1" iconType="solid" size={20} color="F43F47" /> (if available) and choose the environment <Icon icon="circle-2" iconType="solid" size={20} color="F43F47" /> to replay the run in.
![Select a task, then in the bottom right
click "Replay"](/images/replay-run-modal.png)
</Step>
</Steps>
</Tab>
<Tab title="Runs list">
<Steps>
<Step title="Click the action button on a run">
![On the runs page, press the triple dot button](/images/replay-runs-list.png)
</Step>
<Step title="Click replay">![Click replay](/images/replay-runs-list-popover.png)</Step>
</Steps>
</Tab>
</Tabs>
### Detecting replays in your task
You can check if a run is a replay using the [context](/context) object:
```ts
export const myTask = task({
id: "my-task",
run: async (payload, { ctx }) => {
if (ctx.run.isReplay) {
// This run is a replay of a previous run
}
},
});
```
### Replaying using the SDK
You can replay a run using the SDK:
```ts
const replayedRun = await runs.replay(run.id);
```
When you call `trigger()` or `batchTrigger()` on a task you receive back a run handle which has an `id` property. You can use that `id` to replay the run.
You can also access the run id from inside a run. You could write this to your database and then replay it later.
```ts
export const simpleChildTask = task({
id: "simple-child-task",
run: async (payload, { ctx }) => {
// the run ID (and other useful info) is in ctx
const runId = ctx.run.id;
},
});
```
### Bulk replaying
See [Bulk actions](/bulk-actions) for more information.