When a job fails, respect the Retry-After header if applicable

This commit is contained in:
Evan Hahn 2021-09-02 17:31:21 -05:00 committed by GitHub
parent c7873dd7ea
commit 1f45bce0a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 228 additions and 30 deletions

View file

@ -10,17 +10,12 @@ import { isDone as isDeviceLinked } from '../../util/registration';
export async function commonShouldJobContinue({
attempt,
log,
maxRetryTime,
timestamp,
timeRemaining,
}: Readonly<{
attempt: number;
log: LoggerType;
maxRetryTime: number;
timestamp: number;
timeRemaining: number;
}>): Promise<boolean> {
const maxJobAge = timestamp + maxRetryTime;
const timeRemaining = maxJobAge - Date.now();
if (timeRemaining <= 0) {
log.info("giving up because it's been too long");
return false;