Delivery backoff tweaks
ci/woodpecker/tag/ociImageTag Pipeline was successful Details

This commit is contained in:
Natty 2024-11-17 20:04:03 +01:00
parent 5ff8540b22
commit e845eda898
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
2 changed files with 7 additions and 2 deletions

View File

@ -33,6 +33,11 @@ function apBackoff(attemptsMade: number, err: Error) {
const baseDelay = 60 * 1000; // 1min const baseDelay = 60 * 1000; // 1min
const maxBackoff = 8 * 60 * 60 * 1000; // 8hours const maxBackoff = 8 * 60 * 60 * 1000; // 8hours
let backoff = (Math.pow(2, attemptsMade) - 1) * baseDelay; 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.min(backoff, maxBackoff);
backoff += Math.round(backoff * Math.random() * 0.2); backoff += Math.round(backoff * Math.random() * 0.2);
return backoff; return backoff;

View File

@ -76,8 +76,8 @@ export default async (job: Bull.Job<DeliverJobData>) => {
// 5xx etc. // 5xx etc.
throw new Error(`${err.retry_class}: ${err.message}`); throw new Error(`${err.retry_class}: ${err.message}`);
} else { }
throw res; throw res;
} }
}
}; };