diff --git a/src/classes/worker.ts b/src/classes/worker.ts index d929eb0069..32450d31cf 100644 --- a/src/classes/worker.ts +++ b/src/classes/worker.ts @@ -603,8 +603,8 @@ export class Worker< 0, ); - // Blocking for less than 50ms is useless. - if (blockTimeout > 0.05) { + // Blocking for less than 10ms is useless. + if (blockTimeout > this.opts.settings?.blockTimeoutThreshold ?? 0.01) { blockTimeout = this.blockingConnection.capabilities.canDoubleTimeout ? blockTimeout : Math.ceil(blockTimeout); diff --git a/src/interfaces/advanced-options.ts b/src/interfaces/advanced-options.ts index cb463caf18..8c709a642b 100644 --- a/src/interfaces/advanced-options.ts +++ b/src/interfaces/advanced-options.ts @@ -18,4 +18,14 @@ export interface AdvancedOptions extends AdvancedRepeatOptions { * A custom backoff strategy. */ backoffStrategy?: BackoffStrategy; + + /** + * Minimum blocking operation timeout in seconds used when fetching next job. + * If timeout would be smaller than this defined threshold - because of next + * delayed job would be available to be processed sooner - blocking operation + * will not be used. + * + * @defaultValue 0.01 + */ + blockTimeoutThreshold?: number; }