cockatiel icon indicating copy to clipboard operation
cockatiel copied to clipboard

decorrelatedJitterGenerator returns NaN

Open novemberborn opened this issue 1 year ago • 0 comments

Perhaps I'm using it wrong, but after 1025 attempts the jitter in the state goes to Infinity and for the 1026th attempt the delay is NaN.

const { decorrelatedJitterGenerator: d }= require('cockatiel')

const loop = (limit, state = [0,0]) => {
  for(let i = 0; i < limit; i++) {
    let delay;
    ([delay, state] = d(state, { generator: d, exponent: 2, maxDelay: 15*60_000, initialDelay: 45_000 }));
    console.log(delay, state)
  }
}

loop(1026)

Output:

…
900000 [ 1023, 5.201197568175768e+307 ]
900000 [ 1024, 1.3382550381451475e+308 ]
900000 [ 1025, Infinity ]
NaN [ 1026, Infinity ]

novemberborn avatar Jan 22 '24 15:01 novemberborn