groceries: Hoogvliet importer (sitemap SKUs + storefront GraphQL, EANs, promo labels) + store row; Lidl retries transient CDN 401s
Deploy production / deploy (push) Successful in 1m24s
Deploy production / deploy (push) Successful in 1m24s
This commit is contained in:
1 parent
c897ae3d14
commit
942c436d03
7 files changed
+29796
-3
No files matched your search
@@ -15,6 +15,8 @@ export type FetcherOptions = {
|
||||
/** First retry backoff; doubles each try (default 5 s). */
|
||||
retryBaseMs?: number;
|
||||
cacheDir?: string | null;
|
||||
/** Extra 4xx statuses to retry (e.g. a CDN's transient 401/403). */
|
||||
retryStatuses?: number[];
|
||||
log?: (msg: string) => void;
|
||||
};
|
||||
|
||||
@@ -26,6 +28,7 @@ export class PoliteFetcher {
|
||||
cacheHits = 0;
|
||||
private last = 0;
|
||||
private readonly minDelayMs: number;
|
||||
private readonly retryStatuses: number[];
|
||||
private readonly maxRetries: number;
|
||||
private readonly retryBaseMs: number;
|
||||
private readonly dir: string | null;
|
||||
@@ -33,6 +36,7 @@ export class PoliteFetcher {
|
||||
|
||||
constructor(opts: FetcherOptions) {
|
||||
this.minDelayMs = opts.minDelayMs ?? 2000;
|
||||
this.retryStatuses = opts.retryStatuses ?? [];
|
||||
this.maxRetries = opts.maxRetries ?? 5;
|
||||
this.retryBaseMs = opts.retryBaseMs ?? 5000;
|
||||
this.log = opts.log ?? (() => {});
|
||||
@@ -78,7 +82,12 @@ export class PoliteFetcher {
|
||||
return data;
|
||||
}
|
||||
problem = `HTTP ${res.status}`;
|
||||
if (res.status !== 429 && res.status < 500 && res.status !== 408) {
|
||||
if (
|
||||
res.status !== 429 &&
|
||||
res.status < 500 &&
|
||||
res.status !== 408 &&
|
||||
!this.retryStatuses.includes(res.status)
|
||||
) {
|
||||
throw new HttpError(
|
||||
res.status,
|
||||
`${problem} for ${url}: ${(await res.text()).slice(0, 200)}`
|
||||
|
||||
Reference in new issue
Block a user