Skip to content

Commit

Permalink
fix: don't keep retrying after successful result
Browse files Browse the repository at this point in the history
  • Loading branch information
jd1378 committed Oct 6, 2023
1 parent 9cfecb8 commit b473431
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fetch_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ export function wrapFetch(options?: WrapFetchOptions) {
return await fetch(input);
}

const interceptedInit = init || {};
const interceptedInit = (init || {}) as
& (ExtendedRequestInit | RequestInit)
& { headers: Headers }; // to fix header type error

if (!(interceptedInit.headers instanceof Headers)) {
interceptedInit.headers = new Headers(interceptedInit.headers || {});
Expand Down Expand Up @@ -279,6 +281,7 @@ export function wrapFetch(options?: WrapFetchOptions) {

response = await fetch(input, interceptedInit as RequestInit);
clearTimeout(timeoutId);
break; // to break out of while
} catch (e) {
clearTimeout(timeoutId);
if (!retryLimit || attempt >= retryLimit) throw e;
Expand Down

0 comments on commit b473431

Please sign in to comment.