When a job fails, respect the Retry-After
header if applicable
This commit is contained in:
parent
c7873dd7ea
commit
1f45bce0a2
12 changed files with 228 additions and 30 deletions
|
@ -3,11 +3,17 @@
|
|||
|
||||
import type { LoggerType } from '../../logging/log';
|
||||
import { parseIntWithFallback } from '../../util/parseIntWithFallback';
|
||||
import { sleepFor413RetryAfterTimeIfApplicable } from './sleepFor413RetryAfterTimeIfApplicable';
|
||||
|
||||
export function handleCommonJobRequestError(
|
||||
err: unknown,
|
||||
log: LoggerType
|
||||
): void {
|
||||
export async function handleCommonJobRequestError({
|
||||
err,
|
||||
log,
|
||||
timeRemaining,
|
||||
}: Readonly<{
|
||||
err: unknown;
|
||||
log: LoggerType;
|
||||
timeRemaining: number;
|
||||
}>): Promise<void> {
|
||||
if (!(err instanceof Error)) {
|
||||
throw err;
|
||||
}
|
||||
|
@ -18,5 +24,7 @@ export function handleCommonJobRequestError(
|
|||
return;
|
||||
}
|
||||
|
||||
await sleepFor413RetryAfterTimeIfApplicable({ err, log, timeRemaining });
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue