MCPcopy
hub / github.com/stackblitz-labs/pkg.pr.new / fetchWithRetry

Function fetchWithRetry

packages/cli/index.ts:918–933  ·  view source on GitHub ↗
(
  input: URL | string,
  init: RequestInit,
)

Source from the content-addressed store, hash-verified

916}
917
918async function fetchWithRetry(
919 input: URL | string,
920 init: RequestInit,
921): Promise<Response> {
922 const maxRetries = 3;
923 let res = await fetch(input, init);
924 for (let attempt = 1; attempt <= maxRetries && res.status >= 500; attempt++) {
925 const delay = 1000 * 2 ** (attempt - 1); // 1s, 2s, 4s
926 console.warn(
927 `Server error (${res.status}). Retrying in ${delay / 1000}s (attempt ${attempt}/${maxRetries})...`,
928 );
929 await new Promise((resolve) => setTimeout(resolve, delay));
930 res = await fetch(input, init);
931 }
932 return res;
933}
934
935function getFormEntrySize(entry: FormDataEntryValue) {
936 if (typeof entry === "string") {

Callers 1

index.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected