Skip to content

Commit

Permalink
feat(node): add param indicating retry
Browse files Browse the repository at this point in the history
To make retries distinguishable by URL and to invalidate caches.
  • Loading branch information
davidyuk committed Feb 29, 2024
1 parent f348a22 commit 6f0dbd8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils/autorest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ export const genRetryOnFailurePolicy = (

let error = new RestError('Not expected to be thrown');
for (let attempt = 0; attempt <= retryCount; attempt += 1) {
if (attempt !== 0) await pause(intervalsInMs[attempt - 1]);
if (attempt !== 0) {
await pause(intervalsInMs[attempt - 1]);
const urlParsed = new URL(request.url);
urlParsed.searchParams.set('__sdk-retry', attempt.toString());
request.url = urlParsed.toString();
}
try {
return await next(request);
} catch (e) {
Expand Down

0 comments on commit 6f0dbd8

Please sign in to comment.