Skip to content

[4.x] Fix issue with AuthServiceProvider and Laravel Octane - #9240

Merged
jasonvarga merged 1 commit into
statamic:4.xfrom
nadinengland:fix/authserviceprovider-octane
Jan 4, 2024
Merged

jasonvarga merged 1 commit into
statamic:4.xfrom
nadinengland:fix/authserviceprovider-octane

Conversation

@nadinengland

@nadinengland nadinengland commented Dec 22, 2023 •

Copy link
Copy Markdown
Contributor

While getting Statamic working with Octane in our production environments I've hit an issue with AuthServiceProvider using an old instance of the Container.

Octane appears to be working by creating single instances of ServiceProvider for a worker's lifetime but created cloned instances of the Container for each request. The binding callbacks are then re-ran for each request and given the new container instance (a clone of the original.) This even appears to happen for the first request. As such the $this->app will be an instance of an Container that is never used for any request but just for initial registration.

Best practice from the docs suggests using app() or however from testing the $app parameter from the singleton callback appears to be the same instance.

I'll keep raising any other quirks I find but so far so good 👏

@nadinengland nadinengland changed the title Fix issue with AuthServiceProvider and Laravel Octane [4.x] Fix issue with AuthServiceProvider and Laravel Octane Dec 22, 2023
@jasonvarga
jasonvarga merged commit 5992f47 into statamic:4.x Jan 4, 2024
@nadinengland
nadinengland deleted the fix/authserviceprovider-octane branch March 31, 2025 11:56
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.

2 participants