Repository navigation
Conversation
The listener that stored failed jobs was registered by the service provider in every process. `php artisan queue:work` stores failed jobs itself, so with it (e.g. in local development) each failed job was stored twice: with the default `database-uuids` driver, the second insert failed on the unique `uuid` column and that error replaced the job's own exception. The Lambda queue handler now stores failed jobs, like `queue:work` does. This also means that failed jobs are stored even when `bref.log_jobs` is disabled, and that failed `sync` jobs are no longer stored, like in Laravel. The failed job provider is no longer resolved on every boot. Claude-Session: https://claude.ai/code/session_01Awk33iZ9mDSg1xgSAPkgGK
…-jobs-in-queue-handler # Conflicts: # CHANGELOG.md
Base automatically changed from
log-job-exception-when-failer-fails
to
master
September 27, 2026 08:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows #214 (merged).
Problem
BrefServiceProviderregisters aJobFailedlistener that stores failed jobs with the failed job provider. It registers this listener in every process: the Lambda queue worker, but also the web functions, andphp artisan queue:work/queue:listen/ Horizon on a developer's machine.php artisan queue:workalready stores failed jobs itself (WorkCommand::logFailedJob(), also aJobFailedlistener). So in local development, each failed job is stored twice. With Laravel's defaultdatabase-uuidsdriver, the second insert fails on the uniqueuuidcolumn, and that error replaces the job's own exception (see the previous PR for why). This isphp artisan queue:workin a Laravel 13 application with this package installed:The job's exception is never logged. With the
databasedriver (no uniqueuuid), the job is stored twice instead.Two smaller issues come from the same listener:
enableDetailedJobLogging(), so withbref.log_jobsset tofalse, failed jobs are not stored at all on Lambda. That option is documented as "disable detailed logging of every job execution".syncjobs (SyncQueuecallsJob::fail()too). A standard Laravel application does not store them: the exception is thrown to the code that dispatched the job.Fix
QueueHandler, the Lambda equivalent ofqueue:work, now stores failed jobs, the same wayWorkCommanddoes: it registers theJobFailedlistener when it is created. The listener keeps the behavior of the previous PR: if the failed job cannot be stored, it reports that error and does not throw it.Behavior changes:
php artisan queue:work/queue:listen/ Horizon: each failed job is stored once, by Laravel.bref.log_jobs.syncjobs are no longer stored, like in a standard Laravel application. (On the queue worker function, asyncjob dispatched from inside a queued job is still stored, as withqueue:work.)Tests
QueueHandlerTest::testTheFailedJobIsStored: the Lambda handler stores the failed job with the right connection, queue URL and exception.QueueWorkCommandTest:php artisan queue:workwith thedatabase-uuidsdriver stores the failed job once, and only the job's exception is reported. This test fails before the change with theUNIQUE constraint failed: failed_jobs.uuiderror.Tested with Laravel 10, 11, 12 and 13, and on Lambda: a job with
$tries = 1that throws has the same logs as with the previous PR, and its SQS message is deleted.