-
Notifications
You must be signed in to change notification settings - Fork 893
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
Re-establish streams when App Check token expires. #5902
Conversation
🦋 Changeset detectedLatest commit: 27702c1 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 1This report is too large (335,472 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.Test Logs |
.changeset/happy-badgers-leave.md
Outdated
"@firebase/firestore": patch | ||
--- | ||
|
||
Re-establish streams when App Check token expires. |
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 is technically correct, but doesn't quite tell the user what problem this fixes. Can you focus on the user impact?
As discussed offline, the fix is fine given the backend limitations. Can you update the changelog? |
this.appCheckCredentials.start(asyncQueue, () => Promise.resolve()); | ||
this.appCheckCredentials.start(asyncQueue, async newAppCheckToken => { | ||
logDebug(LOG_TAG, 'Received new app check token=', newAppCheckToken); | ||
await this.appCheckCredentialListener(newAppCheckToken); |
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.
await
adds a lot of code for older JS configurations. You can just use return
here and remove async/await.
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.
Done
remoteStoreImpl.onlineStateTracker.set(OnlineState.Unknown); | ||
} | ||
remoteStoreImpl.offlineCauses.delete(OfflineCause.CredentialChange); | ||
await enableNetworkInternal(remoteStoreImpl); |
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.
We don't need a separate method here I think - we should be able to just re-use remoteStoreHandleCredentialChange
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.
Done
.changeset/happy-badgers-leave.md
Outdated
Fixed bug: Firestore listeners stopped working and received a "Permission Denied" | ||
error when App Check token expired (listener was active longer than the App | ||
Check token TTL configured in the Firebase console). The issue does not occur if | ||
listeners were renewed for other reasons such as Authentication token renewal, | ||
listener being idle for a long time, page refresh, etc. |
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.
Maybe:
Fixed bug: Firestore listeners stopped working and received a "Permission Denied" | |
error when App Check token expired (listener was active longer than the App | |
Check token TTL configured in the Firebase console). The issue does not occur if | |
listeners were renewed for other reasons such as Authentication token renewal, | |
listener being idle for a long time, page refresh, etc. | |
Fixed an AppCheck issue that caused Firestore listeners to stop working and receive a | |
"Permission Denied" error. This issue only occurred for AppCheck users that set their | |
expiration time to under an hour |
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.
Done
@@ -234,6 +246,9 @@ export async function setOnlineComponentProvider( | |||
client.setCredentialChangeListener(user => | |||
remoteStoreHandleCredentialChange(onlineComponentProvider.remoteStore, user) | |||
); | |||
client.setAppCheckTokenChangeListener((appCheckToken, 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.
client.setAppCheckTokenChangeListener((appCheckToken, user) => | |
client.setAppCheckTokenChangeListener((_, 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.
Does the AppCheckTokenListener really return the 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.
AppCheckTokenListener only provides the new app check token, not the user. I take the new app check token, as well as the latest user from the firestore_client to call remoteStoreHandleCredentialChange
.
remoteStoreHandleCredentialChange
needs to know the latest user because if the user has changed, it'll do a bunch of things related to user changes. By passing it the current user, that logic will be bypassed and only the restarting of the streams occurs.
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 is a bit of a strange API as the user has nothing to do with the AppCheck token. But I see that this simplifies things a bit, as you otherwise have to manage the current user in yet another place. Let's leave as is for now and remove once the backend fixes the underlying issue.
Co-authored-by: Sebastian Schmidt <mrschmidt@google.com>
Fixes #5842