[4.x] Fix issue with AuthServiceProvider and Laravel Octane - #9240
Merged
jasonvarga merged 1 commit intoJan 4, 2024
Merged
Conversation
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.
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->appwill 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$appparameter from the singleton callback appears to be the same instance.I'll keep raising any other quirks I find but so far so good 👏