-
Notifications
You must be signed in to change notification settings - Fork 896
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
Fix for authStateReady for FirebaseServerApp #8085
Fix for authStateReady for FirebaseServerApp #8085
Conversation
|
Size Report 1Affected Products
Test Logs |
Size Analysis Report 1Affected Products
Test Logs |
response, | ||
idToken | ||
); | ||
await this.directlySetCurrentUser(user); |
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.
Why use directlySetCurrentUser
instead of updateCurrentUser
? directlySetCurrentUser
is rarely used.
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.
I noted that directlySetCurrentUser
was what was being used elsewhere in initializeCurrentUser
where I am calling this from. FWIW we have chosen to disable updateCurrentUser
in FirebaseServerApp. I could use _updateCurrentUser
as @DellaBitta did before but I was concerned that the side effects of notifying listeners and running middleware were undesirable during auth initialization and may lead to more race conditions and ill effects in developer's code.
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.
Perhaps I should rename this method, as it is more appropriately initializeCurrentUserFromIdToken
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.
seconded the rename.
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.
Renamed.
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.
Yeah, the concern of side effects of _updateCurrentUser
makes sense to me. Thanks, let's keep directlySetCurrentUser
then.
response, | ||
idToken | ||
); | ||
await this.directlySetCurrentUser(user); |
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.
Yeah, the concern of side effects of _updateCurrentUser
makes sense to me. Thanks, let's keep directlySetCurrentUser
then.
It turns out the FirebaseServerApp implementation in #8005 was not blocking auth initialization, so when testing end-to-end we were seeing race conditions with auth state. In this PR I address by awaiting the user fetch and moving the implementation into
AuthImpl#initializeCurrentUser
for cleanliness.Mind taking a look @renkelvin?