Skip to content

Queue worker exits prematurely with --max-time due to incorrect $startTime in pauseWorker pathΒ #56505

@hectorjazz

Description

@hectorjazz

Laravel Version

11.45.1

PHP Version

8.2.6

Database Driver & Version

No response

Description

When the queue:work worker is run with the --max-time option and enters a paused state (e.g., during maintenance mode), it exits prematurely.

The root cause is in the Illuminate\Queue\Worker class. The pauseWorker method calls the stopIfNecessary method but fails to pass the required $startTime argument.

As a result, $startTime receives its default value of 0 inside stopIfNecessary, causing the max-time check to pass immediately and the worker to terminate.

The fix is to correct the call in pauseWorker to properly propagate the $startTime argument to stopIfNecessary, ensuring the runtime is calculated correctly.

Steps To Reproduce

  1. Put the Laravel application into maintenance mode:
    php artisan down
  2. Run the queue worker with any --max-time limit:
    php artisan queue:work --max-time=3600
  3. Observe the output. The worker process will exit after the first cycle (e.g., after the sleep duration) instead of continuing to run for the specified max time.

The expected behavior is for the worker to pause and continue its loop, respecting the --max-time limit, even while the application is in maintenance mode.

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