Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/retry-middleware-errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/core": patch
---

Retry `TASK_MIDDLEWARE_ERROR` under the task's retry policy instead of failing the run on the first attempt. The error was already classified as retryable by `shouldRetryError`, but `shouldLookupRetrySettings` did not include it, so the retry flow fell through to `fail_run`. Fixes #3231.
1 change: 1 addition & 0 deletions packages/core/src/v3/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ export function shouldLookupRetrySettings(error: TaskRunError): boolean {
case "TASK_PROCESS_SIGTERM":
case "TASK_PROCESS_SIGSEGV":
case "TASK_RUN_UNCAUGHT_EXCEPTION":
case "TASK_MIDDLEWARE_ERROR":
return true;

default:
Expand Down
6 changes: 6 additions & 0 deletions packages/core/test/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ describe("shouldRetryError + shouldLookupRetrySettings", () => {
expect(shouldLookupRetrySettings(err)).toBe(true);
});

it("retries TASK_MIDDLEWARE_ERROR using the task's retry settings", () => {
const err = internal("TASK_MIDDLEWARE_ERROR");
expect(shouldRetryError(err)).toBe(true);
expect(shouldLookupRetrySettings(err)).toBe(true);
});

it("still does not retry SIGKILL timeout", () => {
expect(shouldRetryError(internal("TASK_PROCESS_SIGKILL_TIMEOUT"))).toBe(false);
});
Expand Down
Loading