Skip to content

Conversation

@cosmastech
Copy link
Contributor

@cosmastech cosmastech commented Jan 14, 2026

To close #58351

Tested this locally. As described in the issue, this spawns an infinite loop. After this change, the job is executed and no infinite loop.


$this->app['events']->listen(function (JobAttempted $event) {
app(DeferredCallbackCollection::class)->invokeWhen(fn ($callback) => $event->connectionName !== 'sync' && ($event->successful() || $callback->always));
app(DeferredCallbackCollection::class)->invokeWhen(static fn ($callback) => ! in_array($event->connectionName, ['sync', 'deferred']) && ($event->successful() || $callback->always));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the comparison be strict i.e. passing true?
I don't know the code practices in here, but I believe for two values, two checks is faster than in_array. Though the difference would be minimal but the two conditions will support short circuiting.

@taylorotwell taylorotwell merged commit 8d0c031 into laravel:12.x Jan 15, 2026
70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Specifying connection deferred on a Job causes an infinite loop starting from v12.45.0 and till current

3 participants