question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FirestoreChangeListener won't receive updates after 1 hour

See original GitHub issue

I have been facing an issue with the real time capabilities of Firestore API. I was reading Firestore documentation when I found out that user authentication tokens expire in 1 hour. This led me to the question: If the token expires in 1 hour, what happens to FirestoreChangeListener after expiration?

I then proceeded to run a simple test to find out. It turns out that FirestoreChangeListener does stop receiving updates after 1 hour. This is the test output:

9/26/2018 8:43:30 AM: Listener started
9/26/2018 8:43:30 AM: Document has changed
9/26/2018 8:43:36 AM: Document has changed // Document actually updated
9/26/2018 8:53:30 AM: Document has changed
9/26/2018 9:03:30 AM: Document has changed
9/26/2018 9:13:30 AM: Document has changed
9/26/2018 9:23:30 AM: Document has changed
9/26/2018 9:33:30 AM: Document has changed
9/26/2018 9:39:45 AM: Document has changed // Document actually updated
9/26/2018 9:40:00 AM: Document has changed // Document actually updated
9/26/2018 9:43:30 AM: Document has changed
// Document updated many times for the next 30 minutes
// No more updates received 

As you can see, after precisely 1 hour, updates are no longer received. It is important to point that I am authenticated with an user account, not a service account. I haven’t tested this behavior using a service account.

It is interesting how FirestoreChangeListener receives an update every 10 minutes even when the document was not changed. That is probably because Firestore resets the stream every 10 minutes. I am wondering if these extra updates are billed.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15

github_iconTop GitHub Comments

1reaction
jskeetcommented, Sep 27, 2018

Hooray. Given that we’ve learned a lot more, I’m going to close this issue so that we can keep track of it in #2542 without confusion.

Thanks for all your efforts tracking things down!

0reactions
pauloevprcommented, Sep 27, 2018

The only thing bothering me now is the fact that the listener invokes the callback every 10 minutes as the stream is reset. It is not a big issue from a billing perspective, but it causes the GUI to update unnecessarily.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android's Firestore's snapshot listener on query takes too ...
It is only after the app has been in the background for too long (say 1-2 hours) and I reopen it that I...
Read more >
The secrets of Firestore's FieldValue.serverTimestamp()
serverTimestamp() value, and; Enforce that clients can only get() documents whose createdAt field contains a timestamp within the past 1 hour.
Read more >
“Why is my Cloud Firestore query slow?” | by Todd ...
Reason #1: It's the data, silly! Probably the most common explanation for a seemingly slow query is that your query is, in fact,...
Read more >
Realtime Updates with SnapshotListener - Firebase Firestore
... can get updates in realtime using firestore's snapshot listener. ⭐ Get certificates for your future job ⭐ Save countless hours of time ......
Read more >
Automatic Upgrade to Firestore - Datastore
Automatic upgrade to Firestore in Datastore mode. View your database type. Upgrade stages. 1. Apply writes synchronously; 2. Copy and verify; 3.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found