fix: exclude HTTP 408 from permanent delivery errors

This commit is contained in:
Benedikt Schackenberg 2026-03-15 19:16:23 +00:00 committed by Benedikt Schackenberg
parent a9fa0064d7
commit 5a0369197e
2 changed files with 10 additions and 1 deletions

View File

@ -61,4 +61,13 @@ describe("isPermanentDeliveryError", () => {
it("returns false for timeout errors", () => {
expect(isPermanentDeliveryError("request timed out")).toBe(false);
});
// 408 should NOT be permanent (request timeout = transient)
it("does NOT treat HTTP 408 as permanent", () => {
expect(isPermanentDeliveryError("status 408")).toBe(false);
});
it("does NOT treat HTTP 408 Request Timeout as permanent", () => {
expect(isPermanentDeliveryError("HTTP 408 Request Timeout")).toBe(false);
});
});

View File

@ -452,7 +452,7 @@ export function isPermanentDeliveryError(error: string): boolean {
const statusMatch = HTTP_STATUS_PATTERN.exec(error);
if (statusMatch) {
const status = parseInt(statusMatch[1], 10);
if (status >= 400 && status < 500 && status !== 429) {
if (status >= 400 && status < 500 && status !== 429 && status !== 408) {
return true;
}
}