-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Provide environment information
n/a
Describe the bug
When a task's middleware throws an error, the run fails immediately without retrying, even when a retry config is set on the task. The error is classified as TASK_MIDDLEWARE_ERROR internally, which is marked as retryable in shouldRetryError, but shouldLookupRetrySettings returns false for this error code, causing the retry flow to fall through to fail_run
Expected: a middleware error should retry using the task's retry config just like a run error would.
Reproduction repo
n/a
To reproduce
- Add the task below.
- Trigger it once.
- Run fails on attempt 1 with TASK_MIDDLEWARE_ERROR and does not retry.
import { logger, task } from "@trigger.dev/sdk";
export const middlewareRetryTask = task({
id: "middleware-retry-task",
retry: {
maxAttempts: 3,
minTimeoutInMs: 500,
maxTimeoutInMs: 1000,
randomize: false,
},
middleware: async ({ ctx, next }) => {
logger.info("Middleware running", { attempt: ctx.attempt.number });
throw new Error("Simulated connection error in middleware");
await next();
},
run: async (payload, { ctx }) => {
return { attempt: ctx.attempt.number };
},
});
Additional information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels