Move files

This commit is contained in:
Andras Schmelczer 2025-02-19 20:47:52 +00:00
parent 6bb051460e
commit dd6f63f357
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
50 changed files with 72 additions and 78 deletions

View file

@ -1,36 +0,0 @@
import * as fetchRetryFactory from "fetch-retry";
import type { RequestInitRetryParams } from "fetch-retry";
import { Logger } from "src/tracing/logger";
const fetchWithRetry = fetchRetryFactory.default(fetch);
function getUrlFromInput(input: RequestInfo | URL): string {
if (input instanceof URL) {
return input.href;
}
if (typeof input === "string") {
return input;
}
return input.url;
}
export async function retriedFetch(
input: RequestInfo | URL,
init: RequestInitRetryParams<typeof fetch> = {}
): Promise<Response> {
return fetchWithRetry(input, {
retryOn: function (attempt, error, response) {
if (error !== null || !response || response.status >= 500) {
Logger.getInstance().warn(
`Retrying fetch for ${getUrlFromInput(input)}, attempt ${attempt}`
);
return true;
}
return false;
},
retries: 6,
retryDelay: (attempt) => Math.pow(1.5, attempt) * 500,
...init
});
}