Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK-2744] Delay restoring state until necessary, rather than in constructor/initialization #550

Merged
merged 2 commits into from
Aug 25, 2021

Conversation

evansims
Copy link
Member

@evansims evansims commented Aug 23, 2021

Changes

A community bug report came in (#543) that reported a bug relating to how some frameworks support lazy loading of classes, and the fact that we restore the end-user state via cookies within the Auth0\SDK\Auth0 constructor, during initialization. I'd not seen this reported before, but I definitely see the benefit of changing this behavior to avoid this sort of side effect.

I've opened this PR resolving this issue by avoiding invoking restoreState() until right before necessary. All references to the private state var have been replaced with calls to the getState() method, which replaces restoreState(), which will restore the state when necessary if it has not already been done so by a preceeding call. This is a cleaner approach anyway.

References

Resolves #543

Contributor Checklist

@evansims evansims marked this pull request as ready for review August 23, 2021 14:36
@evansims evansims requested a review from a team as a code owner August 23, 2021 14:36
@evansims evansims merged commit 7c5e42a into main Aug 25, 2021
@evansims evansims deleted the v8-resolve-constructor-side-effects branch August 25, 2021 14:23
@evansims evansims mentioned this pull request Sep 3, 2021
2 tasks
@evansims evansims added this to the 8.0.0 milestone Sep 3, 2021
@github-actions
Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Side effects in Auth0 constructor
2 participants