Skip to content

Commit

Permalink
Correct exponential backoff.
Browse files Browse the repository at this point in the history
Toward #421.

Still needs unit test that failed first push/pull backs off correctly.
  • Loading branch information
aboodman committed Jul 2, 2021
1 parent 76ae582 commit 470cb2e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/connection-loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ const CONNECTION_MEMORY_COUNT = 9;
// Computes a new delay based on the previous requests. We use the median of the
// previous successfull request divided by `maxConnections`. When we get errors
// we do exponential backoff. As soon as we recover from an error we reset back
// to MIN_DELAY_MS.
// to delegate.minDelayMs.
function computeDelayAndUpdateDurations(
delay: number,
delegate: ConnectionLoopDelegate,
Expand All @@ -217,7 +217,7 @@ function computeDelayAndUpdateDurations(
const {duration, ok} = sendRecords[sendRecords.length - 1];

if (!ok) {
return delay * 2;
return delay == 0 ? 1 : delay * 2;
}

const {maxConnections, minDelayMs} = delegate;
Expand Down

1 comment on commit 470cb2e

@arv
Copy link
Contributor

@arv arv commented on 470cb2e Jul 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like you can set initial delay to 1.

Please sign in to comment.