-
Notifications
You must be signed in to change notification settings - Fork 936
Fix App Check state setting and promise clearing #6740
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
Conversation
🦋 Changeset detectedLatest commit: 94f9785 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size Report 1Affected Products
Test Logs |
Size Analysis Report 1Affected Products
Test Logs |
I think it is better than my code, but it seems to be prone to bugs because the information rewritten in the setter is not immediately reflected in the local state. Performance may be somewhat degraded, but I thought it would be safer and more readable to stop using setter and getter and use mutex to execute the entire function exclusively. |
That's true, we would have to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #6734 (probably)?
Based on solution suggested in #6735
setState()
andstate
usage is already pretty inconsistent throughout the App Check codebase (sometimes immutable, sometimes mutated) and I don't think the best answer is to continue mixing. Additionally, the waysetState()
is used depends on extending a temporary version ofstate
that, due to a lot of async code, may be stale by the time itsetState()
is called.set()
is now only done once per key (a FirebaseApp) on theAPP_CHECK_STATES
, on initialization. ChangedsetState()
tosetIInitialState()
to make this clear. The Map will now only be used to store a reference to this object, which should never be overwritten. Any further changes can be made by mutating this object's properties.getState()
is changed togetStateReference()
to make it clear it will just get you a reference to this object.This seems like the best way to deal with instantly setting state on an object when it can be done through any number of dangling promises.