Version
v5.66.5
Platform
NodeJS
What happened?
worker.resume() does nothing after calling worker.pause(true) [doNotWaitActive=true]. The worker remains permanently stuck with isRunning()=true and isPaused()=true.
Root Cause
pause(true) sets this.paused = true but skips whenCurrentJobsFinished(), so the main loop hasn't exited and this.running is still true.
resume() checks if (!this.running) since running is true, it bails out without doing anything.
With pause(false) the default, whenCurrentJobsFinished() awaits mainLoopRunning, the loop exits, running becomes false in the finally block, and resume() works. But pause(true) skips this, creating a state where resume() can never succeed.
How to reproduce.
const worker = new Worker('test', async (job) => {
await new Promise(resolve => setTimeout(resolve, 5000))
}, { connection: redis })
// Add a job so the worker is processing
await queue.add('test', {})
// Wait for it to become active
await new Promise(resolve => setTimeout(resolve, 1000))
// Pause without waiting for active jobs
await worker.pause(true)
// Try to resume
worker.resume()
console.log(worker.isRunning()) // true
console.log(worker.isPaused()) // true — still paused, resume() was a no-op
Context
This is particularly problematic when trying to recover workers after a Redis cluster connection failure (ClusterAllFailedError). Using pause(false) hangs because whenCurrentJobsFinished() tries to disconnect the blocking connection which is already dead. Using pause(true) avoids the hang but makes resume() impossible.
Relevant log output
Code of Conduct
Version
v5.66.5
Platform
NodeJS
What happened?
worker.resume()does nothing after callingworker.pause(true)[doNotWaitActive=true]. The worker remains permanently stuck withisRunning()=trueandisPaused()=true.Root Cause
pause(true)setsthis.paused = truebut skipswhenCurrentJobsFinished(), so the main loop hasn't exited andthis.runningis stilltrue.resume()checks if(!this.running)since running is true, it bails out without doing anything.With
pause(false)the default,whenCurrentJobsFinished()awaits mainLoopRunning, the loop exits, running becomes false in the finally block, andresume()works. Butpause(true)skips this, creating a state whereresume()can never succeed.How to reproduce.
Context
This is particularly problematic when trying to recover workers after a Redis cluster connection failure (ClusterAllFailedError). Using pause(false) hangs because whenCurrentJobsFinished() tries to disconnect the blocking connection which is already dead. Using pause(true) avoids the hang but makes resume() impossible.
Relevant log output
Code of Conduct