Wrong type for BackoffOptions
Description
The BackoffOptions
interface contains three parameters: type
, delay
and strategyOptions
. The issue here is with strategyOptions
. It should be named as options
instead, as this is what is expected in the Job
here.
Minimal, Working Test code to reproduce the issue.
const myQueue = new Queue('Server B', {
settings: {
backoffStrategies: {
// truncated binary exponential backoff
binaryExponential: function (attemptsMade, err, options) {
// Options can be undefined, you need to handle it by yourself
if (!options) {
options = {}
}
const delay = options.delay || 1000;
const truncate = options.truncate || 1000;
console.error({ attemptsMade, err, options });
return Math.round(Math.random() * (Math.pow(2, Math.max(attemptsMade, truncate)) - 1) * delay)
}
}
}
});
myQueue.add({ foo: 'bar' }, {
attempts: 10,
backoff: {
type: 'binaryExponential',
options: { // this is defined as strategyOptions: any; and not options: any;
delay: 500,
truncate: 5
}
}
});
(An easy to reproduce test case will dramatically decrease the resolution time.)
Bull version
4.10.3