Skip to content
This repository was archived by the owner on Oct 16, 2023. It is now read-only.
This repository was archived by the owner on Oct 16, 2023. It is now read-only.

Jitter should be relative to the current delay #5

Description

@mokesmokes

E.g. in https://github.com/segmentio/backo/blob/master/index.js#L38
perhaps try something like:

if (this.jitter) {
  var rand =  Math.random();
  var deviation = rand * this.jitter * ms; // 0 <= jitter <= 1
  ms = (Math.floor(rand * 10) & 1) == 0  ? ms - deviation : ms + deviation;  // so jitter is uniformly distributed on both sides
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions