Skip to content

[Bug]: resume() is a no-op after pause(true), worker stays stuck #3971

@krazibit

Description

@krazibit

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

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions