From 5a0369197ec58d67a94a8eb7532ab96842028787 Mon Sep 17 00:00:00 2001 From: Benedikt Schackenberg Date: Sun, 15 Mar 2026 19:16:23 +0000 Subject: [PATCH] fix: exclude HTTP 408 from permanent delivery errors --- src/infra/outbound/delivery-queue.test.ts | 9 +++++++++ src/infra/outbound/delivery-queue.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/infra/outbound/delivery-queue.test.ts b/src/infra/outbound/delivery-queue.test.ts index f22f82af2ef..63a7b5a9abe 100644 --- a/src/infra/outbound/delivery-queue.test.ts +++ b/src/infra/outbound/delivery-queue.test.ts @@ -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); + }); }); diff --git a/src/infra/outbound/delivery-queue.ts b/src/infra/outbound/delivery-queue.ts index 193fe33ddcf..6af947c1ea1 100644 --- a/src/infra/outbound/delivery-queue.ts +++ b/src/infra/outbound/delivery-queue.ts @@ -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; } }