Skip to content

Commit

Permalink
feat(retry): nits
Browse files Browse the repository at this point in the history
Refs: #1667
Signed-off-by: Jonah Kaye <[email protected]>
  • Loading branch information
jonahkaye committed Jun 20, 2024
1 parent 0dc46e5 commit 178bc81
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions packages/shared/src/net/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const defaultOptions: ExecuteWithNetworkRetriesOptions = {
"ECONNREFUSED", // (Connection refused): No connection could be made because the target machine actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host.
"ECONNRESET", // (Connection reset by peer): A connection was forcibly closed by a peer. This normally results from a loss of the connection on the remote socket due to a timeout or reboot. Commonly encountered via the http and net modules.
],
httpStatusCodesToRetry: [tooManyRequestsStatus], // 429 Too Many Requests
httpStatusCodesToRetry: [tooManyRequestsStatus],
retryOnTimeout: false,
};

Expand Down Expand Up @@ -59,21 +59,14 @@ function networkGetTimeToWait({
error,
}: GetTimeToWaitParams) {
const status = getHttpStatusFromError(error);
if (status === tooManyRequestsStatus) {
return defaultGetTimeToWait({
initialDelay: initialDelay * tooManyRequestsMultiplier,
backoffMultiplier,
attempt,
maxDelay,
});
} else {
return defaultGetTimeToWait({
initialDelay,
backoffMultiplier,
attempt,
maxDelay,
});
}
const effectiveInitialDelay =
status === tooManyRequestsStatus ? initialDelay * tooManyRequestsMultiplier : initialDelay;
return defaultGetTimeToWait({
initialDelay: effectiveInitialDelay,
backoffMultiplier,
attempt,
maxDelay,
});
}

/**
Expand Down

0 comments on commit 178bc81

Please sign in to comment.