diff --git a/packages/backend/src/queue/initialize.ts b/packages/backend/src/queue/initialize.ts index 0686fe9cd3..a6164d50fb 100644 --- a/packages/backend/src/queue/initialize.ts +++ b/packages/backend/src/queue/initialize.ts @@ -33,6 +33,11 @@ function apBackoff(attemptsMade: number, err: Error) { const baseDelay = 60 * 1000; // 1min const maxBackoff = 8 * 60 * 60 * 1000; // 8hours let backoff = (Math.pow(2, attemptsMade) - 1) * baseDelay; + + if (err?.message?.startsWith("RetriableLater")) { + backoff += (Math.pow(1.5, attemptsMade) - 1) * baseDelay * 10 * attemptsMade; + } + backoff = Math.min(backoff, maxBackoff); backoff += Math.round(backoff * Math.random() * 0.2); return backoff; diff --git a/packages/backend/src/queue/processors/deliver.ts b/packages/backend/src/queue/processors/deliver.ts index 4021903045..70effb871d 100644 --- a/packages/backend/src/queue/processors/deliver.ts +++ b/packages/backend/src/queue/processors/deliver.ts @@ -76,8 +76,8 @@ export default async (job: Bull.Job) => { // 5xx etc. throw new Error(`${err.retry_class}: ${err.message}`); - } else { - throw res; } + + throw res; } };