Skip to content

Commit

Permalink
perf(worker): reset delays after generating blockTimeout value (#2529)
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf authored Apr 21, 2024
1 parent 8ed041e commit e92cea4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/classes/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ export class Worker<
try {
this.blockUntil = await this.waiting;

if (this.blockUntil <= 0 || this.blockUntil - Date.now() < 10) {
if (this.blockUntil <= 0 || this.blockUntil - Date.now() < 1) {
return this.moveToActive(client, token, this.opts.name);
}
} catch (err) {
Expand Down Expand Up @@ -626,6 +626,7 @@ export class Worker<
? blockTimeout
: Math.ceil(blockTimeout);

this.updateDelays(); // reset delays to avoid reusing same values in next iteration
// Markers should only be used for un-blocking, so we will handle them in this
// function only.
const result = await bclient.bzpopmin(this.keys.marker, blockTimeout);
Expand Down

0 comments on commit e92cea4

Please sign in to comment.