8000 [12.x] Resolve the correct queue factory when using laravel octane by BertvanHoekelen · Pull Request #58530 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@BertvanHoekelen
Copy link
Contributor

This change breaks sending queued notifications when used with Laravel Octane. The first request proceeds as usual, however the on the second request I get Target [Illuminate\Contracts\Queue\Factory] is not instantiable.. This PR should resolve that issue

@BertvanHoekelen BertvanHoekelen changed the title Resolve the correct queue factory when using laravel octane [12.x] Resolve the correct queue factory when using laravel octane Jan 28, 2026
@marius-ciclistu
Copy link

Hi. Can you please explain this change? At first look it does the same thing.

@webard
Copy link
Contributor
webard commented Jan 28, 2026

@BertvanHoekelen
Copy link
Contributor Author

Correct, it's about the container injection when you use octane. On the first request it's still available, but on all subsequent requests it cannot resolve the QueueFactoryContract.

Previously the notification sender was recreated on all requests and not cached in the notificationSender prop here

@marius-ciclistu
Copy link

@rodrigopedra FYI.

@rodrigopedra
Copy link
Contributor

This PR should resolve that issue

It should, or it does?

Can you add a test case to show the issue?

I don't understand how this change solves the issue, especially when the dispatcher holds the $app instance you are saying becomes faulty on subsequent requests and uses it to solve command handlers.

Why does the $app instance work for instantiating command handlers and not the queue drivers (from the Illuminate\Contracts\Queue\Factory)?

And how is this related to the NotificationSender instance being kept?

If there is an issue with re-instantiating Illuminate\Contracts\Queue\Factory, then generating a new instance every time should be worse than keeping the previous instance, right?

Do you have a public repository where we can easily reproduce this issue?

@BertvanHoekelen
Copy link
Contributor Author

It does fix the issue. I have no idea how to add a test for this as it only happens when octane is used.

@rodrigopedra I don't know exactly why this is the case, you can read more about it in the documentation.

@rodrigopedra
Copy link
Contributor

@BertvanHoekelen later on the link you sent, we can read this:

This may not be a problem for your particular application; however, it can lead to the container unexpectedly missing bindings that were added later in the boot cycle or by a subsequent request.

Reference https://laravel.com/docs/12.x/octane#container-injection

"...container unexpectedly missing bindings that were added later in the boot cycle" is not the case for the Illuminate\Contracts\Queue\Factory which is registered in a service provider's register method.

I created the repository below to test the issue and cannot reproduce the issue:

https://github.com/rodrigopedra/pr-58530

It works as expected without errors. I tested only using the FrankenPHP driver, but you can try others if needed.

Can you review what I might be doing wrong? And guide us on how to reproduce it?

@taylorotwell taylorotwell merged commit 8353ff7 into laravel:12.x Jan 28, 2026
20 of 70 checks passed
@taylorotwell
Copy link
Member

Merging as this is directionally the correct way to be Octane compatible at least.

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.

5 participants

0