MCPcopy Create free account
hub / github.com/vercel/vercel / fetchWithRetry

Function fetchWithRetry

packages/cli/test/dev/utils.ts:61–82  ·  view source on GitHub ↗
(url: string, opts: FetchOptions = {})

Source from the content-addressed store, hash-verified

59};
60
61export function fetchWithRetry(url: string, opts: FetchOptions = {}) {
62 return retry(
63 async () => {
64 const res = await nodeFetch(url, opts);
65
66 if (res.status !== opts.status) {
67 const text = await res.text();
68 throw new Error(
69 `Failed to fetch "${url}", received ${res.status}, expected ${
70 opts.status
71 }, id: ${res.headers.get('x-vercel-id')}:\n\n${text}\n\n`
72 );
73 }
74
75 return res;
76 },
77 {
78 retries: opts.retries ?? 3,
79 factor: 1,
80 }
81 );
82}
83
84type ResolverPromise<T> = Promise<T> & {
85 resolve: (value: PromiseLike<null> | null) => void;

Callers 2

testPathFunction · 0.85

Calls 3

retryFunction · 0.85
textMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected