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.
Defer check whether auth is available #4845
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
Defer check whether auth is available #4845
Changes from 1 commit
99b79f6
1ff8800
c15ae9f
41b5dc5
51718f1
55590e6
3624380
0faa3d9
958bcdf
bc06883
be1fa3c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
This variable doesn't seem to do anything, because it's only set in
awaitTokenAndRaiseInitialEvent
which is synchronous. It's not used inawaitTokenAndRaiseInitialEvent()
itself and is always set to true at the end of the function, so it seems the outside world will always see this variable astrue
.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.
Hm, this bothers me. It is meant to prevent double-firing of the change listener. I tested that it doesn't fire twice manually, but what you say is also true - this variable and its check do not do anything. I have fixed the variable and am now resetting it on the queue rather than synchronously.
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.
In the
registerAuth()
, we doWe already invoke
this.changeListener
in the asyncQueue inawaitTokenAndRaiseInitialEvent
, should we not do it again inthis.tokenListener
?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 think I addressed this. I am not able to verify this right now, but will do a test run later today. BTW, this was meant to be addressed by the buggy code around
initialEventRaised
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.
Comment needs update.
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.
Fixed
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.
Is
this.asyncQueue
set at this point?My understanding is it is not, so
awaitTokenAndRaiseInitialEvent
doesn't do anything except for settingthis.invokeChangeListener = false;
which will lead to wrong behavior if auth is not available - the following code in this.tokenListener` will not execute: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.
This seems to work in code though. Firestore will not receive a null user when auth is not initialized, but nothing seems to break.
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 changed the logic for
invokeChangeListener
to only set it to true if the AsyncQueue is available. This should address this concern.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.
Do you mean asynchronously, since it happens in the asyncQueue?
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 meant "synchronously with the code that resolves the token". I have reworded it.
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.
then
only fires ifawaitToken
resolves, why do we resolve it again inthen
? The comment suggests it ensures all previous Promises also get resolved? But I don't get how that works.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.
This was meant to resolve the existing this.receivedUser Promise if another one was created later on. I changed how the listener gets called if auth is not used, and am no longer using the Promise twice. This allowed me to remove this logic.