Skip to content

Firestore onSnapshot() fails to complete on app restart #5058

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

Closed
L1b3rtyy opened this issue Jun 22, 2021 · 4 comments
Closed

Firestore onSnapshot() fails to complete on app restart #5058

L1b3rtyy opened this issue Jun 22, 2021 · 4 comments

Comments

@L1b3rtyy
Copy link

  • Operating System version: _____ iOS 14.4.2
  • Browser version: _____ Safari 14.4.2
  • Firebase SDK version: _____ 8.6.7
  • Firebase Product: _____ Firestore

Steps to reproduce:

When my app starts, a snapshot is started (using the onSnapshot() method) on the document containing the current's user data.
My issue is that when I restart the app, this snapshot will "sometimes" never return any value, even though there is a document.
The only solution then is to kill the app (double click on Home then swipe up the app screen) and start it again, then everything works fine again.

How I restart the app:

window.location.assign(window.location.origin);

Logs (the SDK's logs are mixed with the ones from my app, I removed the irrelevant ones from my app):

LOG - [2021-06-22T14:33:15.403Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|377333871|null
LOG - [2021-06-22T14:33:15.401Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|377333871|1
LOG - [2021-06-22T14:33:15.360Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|965110029|null
LOG - [2021-06-22T14:33:15.344Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|965110029|1
LOG - [2021-06-22T14:33:15.179Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|291602727|null
LOG - [2021-06-22T14:33:15.178Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|291602727|1
LOG - [2021-06-22T14:33:15.177Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|__sak|null
LOG - [2021-06-22T14:33:15.176Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|__sak|1
LOG - [2021-06-22T14:33:15.174Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|591487729|null
LOG - [2021-06-22T14:33:15.172Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|591487729|1
LOG - [2021-06-22T14:33:15.170Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|290269970|null
LOG - [2021-06-22T14:33:15.169Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|290269970|1
LOG - [2021-06-22T14:33:15.167Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|709914748|null
LOG - [2021-06-22T14:33:15.166Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|709914748|1
LOG - [2021-06-22T14:33:15.165Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|__sak|null
LOG - [2021-06-22T14:33:15.163Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|__sak|1
LOG - [2021-06-22T14:33:15.161Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|185710931|null
LOG - [2021-06-22T14:33:15.160Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|185710931|1
LOG - [2021-06-22T14:33:15.158Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|272417711|null
LOG - [2021-06-22T14:33:15.156Z] @firebase/firestore:Firestore (8.6.7): SharedClientState|EVENT|272417711|1
LOG - [2021-06-22T14:33:12.973Z] @firebase/firestore:Firestore (8.6.7): SimpleDb|Opening database:firestore/[DEFAULT]/fireauthentest/main
LOG - [2021-06-22T14:33:12.972Z] @firebase/firestore:Firestore (8.6.7): IndexedDbPersistence|Starting transaction:updateClientMetadataAndTryBecomePrimary
LOG - [2021-06-22T14:33:12.967Z] @firebase/firestore:Firestore (8.6.7): FirestoreClient|Initializing OfflineComponentProvider
LOG - [2021-06-22T14:33:12.949Z] @firebase/firestore:Firestore (8.6.7): FirestoreClient|Received user=ZZNtKb3byiQsrHZ4I4A3IyfDZWL2
LOG - [2021-06-22T14:33:12.947Z] backenduser.setusersnapshot - uid=ZZNtKb3byiQsrHZ4I4A3IyfDZWL2
LOG - [2021-06-22T14:33:12.941Z] backendchat_stateless.getchatsbystate - ptcpuid=ZZNtKb3byiQsrHZ4I4A3IyfDZWL2, chatstate=10
LOG - [2021-06-22T14:33:12.941Z] backendchat.getchats ptcpuid=ZZNtKb3byiQsrHZ4I4A3IyfDZWL2
LOG - [2021-06-22T14:33:12.938Z] mylogin.mounted.onAuthStateChanged - user set
LOG - [2021-06-22T14:33:12.194Z] app.mounted - version=dev_0.0.1555, OS detected=iOS, appversion=5.0 (iPhone; CPU iPhone OS 14_4_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1

Notes regarding the logs:

  • "mylogin.mounted.onAuthStateChanged - user set" is when auth.onAuthStateChanged is triggered with a valid user, hence the user is logged in
  • "backenduser.setusersnapshot - uid=ZZNtKb3byiQsrHZ4I4A3IyfDZWL2" is when the snapshot is triggered
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@wu-hui
Copy link
Contributor

wu-hui commented Jun 24, 2021

Hi @olivierkrener

Thanks for reporting the issue and the logs.

The log does show there is a user signing in, however, the logs around snapshot listeners are no there. Can you check if there are more logs?

If these are all the logs you have, is it possible for you to provide a mini-repo, along with instructions. I did a simple repo, and do not see the error.

@google-oss-bot
Copy link
Contributor

Hey @olivierkrener. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@google-oss-bot
Copy link
Contributor

Since there haven't been any recent updates here, I am going to close this issue.

@olivierkrener if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

@firebase firebase locked and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants