Skip to content

queue:work daemon enters infinite silent loop when getNextJob() throws non-database exceptions #59517

Description

@thuggins-engrain

Laravel Version

11.46.0

PHP Version

8.2.27

Database Driver & Version

No response

Description

Worker::getNextJob() has a catch (Throwable) block with no retry limit. If the queue connection throws a non-database exception (e.g., SQS SDK timeout, auth error, HTTP failure), the worker enters an infinite loop: catch → sleep(1) → retry → catch → forever.

// Worker.php:372-378
} catch (Throwable $e) {
    $this->exceptions->report($e);
    $this->stopWorkerIfLostConnection($e);  // only checks DATABASE errors
    $this->sleep(1);
}

stopWorkerIfLostConnection() uses DetectsLostConnections which only matches MySQL/PostgreSQL/SQLite error strings. Queue connection failures (SQS, Redis, etc.) don't match, so shouldQuit is never set.

The worker also has no pcntl_alarm active during getNextJob() — the timeout handler is only registered during runJob() and cleared at resetTimeoutHandler() before the next call.

Impact: Worker container stays "Up" but processes zero messages indefinitely. In production we observed 4 of 7 workers stuck in this state for days.

Steps To Reproduce

Steps To Reproduce

  1. Run php artisan queue:work --queue=any-queue with a queue driver that throws on pop() (e.g., SQS with invalid credentials, or a mock driver)
  2. Worker loops forever in getNextJob() catch block
  3. --timeout, --memory, and --max-time do not stop it

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions