published fresh until

Laravel: queue slow work and retry failures safely

Summary Bound worker attempts and timeout, delay dispatch until commit, and retry only the selected failed-job ID after checking idempotency. Start with php artisan queue:failed

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: run the worker with an explicit --timeout several seconds shorter than the connection's retry_after, then select finite attempts and delayed retries.

Short answer

As of November 2026, this card targets the maintained security line Laravel 12, not a claim about the latest major. Use idempotent side effects before exposing a manual retry button.

Choose / don't choose

  • ShouldBeUnique: choose dispatch deduplication; don't treat it as a processing lock for every replay path. The queue guide describes the dispatch lock.
  • WithoutOverlapping: choose exclusion while a job executes, keyed to the protected resource; don't assume it guarantees exactly-once effects. Manual retries still need idempotency. The middleware API exposes release and expiry controls.

Not for: diagnosing synchronous endpoint latency; see laravel-speed-up-slow-page-endpoint-query-or-php-profile.

Settings that matter

Setting or flagValue / defaultApplies toSource
--timeoutDefault 60 seconds; choose below retry_after by several secondsLinked worker implementation and queue connectioncommand, guide
retry_afterLonger than --timeout; SQS uses visibility timeout insteadLinked queue docsguide
queue:work --triesDefault 1; example policy 3; 0 means unlimited, so avoid it for bounded service retriesLinked worker implementationcommand, guide
queue:work --backoffDefault 0 seconds; example policy 3 seconds between exception retriesLinked worker implementationcommand, guide
after_commit / afterCommit()Connection true makes Laravel wait for open parent transactions; use per-dispatch afterCommit() when its records must be committed firstLinked queue docsguide
releaseAfter()Positive delay in seconds to release the job back to the queue; choose from contentionLinked middleware APIAPI
expireAfter()Explicit lock expiry long enough for the bounded operationLinked middleware APIAPI
shared()Enable when different job classes protect the same resource keyLinked middleware APIAPI

Order of operations

1. Make the external effect idempotent with a stable operation ID. Separate a retryable delivery attempt from a business operation already completed; a queue lock cannot undo a duplicate remote charge. 2. Dispatch after commit when the job needs newly written rows. Example worker policy: php artisan queue:work --timeout=60 --tries=3 --backoff=3; choose a connection retry_after above that timeout, such as 90 seconds, only if the job fits this budget (queue guide, command definition). 3. Inspect php artisan queue:failed; retry only the selected identifier with php artisan queue:retry <id>. Avoid all for an individual recovery (guide). 4. For an operator UI, authorize each retry, show redacted failure metadata, record the selected ID and operator, and prevent repeated clicks. Check idempotency and current resource state before retrying. These are application controls; the CLI does not supply their authorization model.

Known failures and fixes

Error (short quote)CauseFixSource
MaxAttemptsExceededExceptionAttempts exhausted; overlap releases can consume attemptsInspect the failure before replay; tune overlap release delay and finite attempts togetherexception API, queue guide
“does not acquire the UniqueLock”Historical issue describes interaction between released jobs and dispatch uniquenessUse a processing lock and idempotency for execution safety; do not infer replay exclusion from uniqueness aloneLaravel issue 48013

The dated unique-job discussion 47852 describes attempts resetting on manual retry. Treat a replay as a new execution opportunity, with its own operator and idempotency checks.

Missing

  • The linked source does not confirm: Queue dispatch and concurrency locks solve different problems.
  • Queue driver, maximum legitimate runtime and external request timeouts are unspecified. No universal timeout or lock expiry is safe for all jobs.
  • Job-level retry policy may override worker options; inspect the actual job before promising an operator a fixed retry count.

Started from a post by @Laravel, packaged by the editor. Original post

Subjects

More in security

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Laravel: queue slow work and retry failures safely
Summary: Bound worker attempts and timeout, delay dispatch until commit, and retry only the selected failed-job ID after checking idempotency. Start with `php artisan queue:failed`
Copy for agent
get the whatworks thread laravel-queue-timeouts-failed-jobs-safe-retry and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread laravel-queue-timeouts-failed-jobs-safe-retry
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks