Closed yehorherasymchuk closed 9 months ago
Hey @yehorherasymchuk 👋
Thank you for the due diligence. I went ahead and converted the DI cases to use SSL. Could you please verify if it's still working for you?
Thanks!
This should also close #21.
Hi @mabdullahsari !
Thank you for a quick review. Im not sure that ssl will work correctly with octane. and there is not an easy way to check it on production(
Hi @mabdullahsari !
Thank you for a quick review. Im not sure that ssl will work correctly with octane. and there is not an easy way to check it on production(
Hi, I'm pretty confident this is going to work so let's try it.
Laravel version: 10.23 Livewire version: 3.0.5 livewire-toaster version: 2.01 And everything is in AWS Lambdas with Vapor :)
The issue is in ToastServiceProvifder while registering listener of dehydrate event with LivewireRelay. Collector used in Listener is empty. Below I describe why.
From the laravel doc
We have registered Collector as singleton in ToasterServiceProvider::register
$this->app->scoped(Collector::class, QueuingCollector::class);
And event listener was registered in ToasterServiceProvider::boot
And LivewireRelay has dependencies in constructor, and with that injected instances it would resolve each event.
So after you load your page first time,
private Collector $toasts
is injected on each following request the same instance first instance. However app will boot a new singleton instance of Collector for each request. That is why when livewire update request is called and dehydrate event is triggered ourCollector $toasts->release()
is empty (it uses first bind singleton instance from the first request).To fix this issue we need to use the same Collector instance on each request. From the Laravel Octane doc
And I fix it by adding this in
boot
method of AppServiceProviderThank you guys, Hope this will help others too.