Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(retry): miscellaneous improvements to the default retry mechanisms #120

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions packages/node/src/retry/defaultRetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export class RetryHandler extends BaseRetryHandler {
for (let numRetries = 0; numRetries < this._options.retryTimeouts.length; numRetries++) {
const sleepDuration = this._options.retryTimeouts[numRetries];
await asyncSleep(sleepDuration);
const isLastTry = numRetries === this._options.retryTimeouts.length;
const isLastTry = numRetries === this._options.retryTimeouts.length - 1;
const eventsToRetry = eventsBuffer.slice(0, eventCount);
const { shouldRetry, shouldReduceEventCount, eventIndicesToRemove } = await this._retryEventsOnce(
userId,
Expand All @@ -253,12 +253,11 @@ export class RetryHandler extends BaseRetryHandler {
});

eventCount -= numEventsRemoved;
this._eventsInRetry -= eventCount;
if (eventCount < 1) {
break; // If we managed to remove all the events, break off early.
}
this._eventsInRetry -= numEventsRemoved;
}
if (!shouldRetry) {

// If we managed to remove all the events or the payload should no longer be tried, break off early.
if (!shouldRetry || eventCount < 1) {
break; // We ended!
}

Expand Down