Skip to content

Commit 8d59130

Browse files
committed
fix(core): retry TASK_MIDDLEWARE_ERROR under the task's retry policy
1 parent 6b46a34 commit 8d59130

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@trigger.dev/core": patch
3+
---
4+
5+
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.

packages/core/src/v3/errors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ export function shouldLookupRetrySettings(error: TaskRunError): boolean {
427427
case "TASK_PROCESS_SIGTERM":
428428
case "TASK_PROCESS_SIGSEGV":
429429
case "TASK_RUN_UNCAUGHT_EXCEPTION":
430+
case "TASK_MIDDLEWARE_ERROR":
430431
return true;
431432

432433
default:

packages/core/test/errors.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,12 @@ describe("shouldRetryError + shouldLookupRetrySettings", () => {
263263
expect(shouldLookupRetrySettings(err)).toBe(true);
264264
});
265265

266+
it("retries TASK_MIDDLEWARE_ERROR using the task's retry settings", () => {
267+
const err = internal("TASK_MIDDLEWARE_ERROR");
268+
expect(shouldRetryError(err)).toBe(true);
269+
expect(shouldLookupRetrySettings(err)).toBe(true);
270+
});
271+
266272
it("still does not retry SIGKILL timeout", () => {
267273
expect(shouldRetryError(internal("TASK_PROCESS_SIGKILL_TIMEOUT"))).toBe(false);
268274
});

0 commit comments

Comments
 (0)