Description
Operating System
iOS 17.4
Browser Version
Safari 604.1
Firebase SDK Version
10.9.0, 10.8.1
Firebase SDK Product:
Firestore
Describe your project's tooling
React, Next.js, Capacitor
Describe the problem
Over the months, we noticed some errors were always logged in Sentry, such as:
- UnknownError: Attempt to get a record from database without an in-progress transaction
- UnknownError: Attempt to get all index records from database without an in-progress transaction
- UnknownError: Connection to Indexed Database server lost. Refresh the page to try again
- FIRESTORE (10.7.0) INTERNAL ASSERTION FAILED: Unexpected state
- Non-Error promise rejection captured with value: null
We always saw them, but never received any bug reports about broken sync, so we just shrugged them off as recoverable.
iOS 17.4
Since latest iOS, we noticed that sync stopped working sometimes. After focusing on this problem, it turned out it's likely to fail if app is running in the background, and is brought to foreground.
I want to stress that we are handling onError
in our snapshot listeners, and restart the subscriptions in such case. However, the onError
callback was never getting called, it would just stop working.
Coming back to app running in the background would often look like this:
So it shows the error, and snapshots are not working anymore.
Previous versions of iOS
To be clear, the errors above were also logged pre-iOS 17.4. But we didn't receive reports of broken sync before, and the errors were also less frequent.
For example, the "Connection to Indexed Database server lost" error is now most common on 17.4 after only few days that it's been out:

Logged errors
Whenever I encountered a failure, it always came with the INTERNAL ASSERTION FAILED
error.
Sometimes, I logged other errors mentioned at the top - while app was still in the background.
Logging
I wanted to capture more information, but strangely whenever I set logging to firestore.setLogLevel('debug')
, I couldn't repro once. And I tried many times.
After switching back to firestore.setLogLevel('error')
, I was able to repro again.
iPhone state
I haven't noticed anything special about the state - things such as battery %, battery saving mode don't seem to have any effect. Also it didn't matter whether I flooded memory with other apps or not. (Obviously I didn't flood the memory enough for app to be terminated.)
Firebase versions
Reproduced on both 10.8.1 and 10.7.0.
Steps and code to reproduce issue
We don't have a repo with clean reproduction, but I want to explain how we can reproduce it in our app.
- Run the Capacitor app on a phone
- Switch to other apps. Use the device normally, but don't reopen the app
- Wait 5 minuts
- Make changes on another device
- Reopen the app. The changes aren't showing up, and the
FIRESTORE (10.7.0) INTERNAL ASSERTION FAILED: Unexpected state
is thrown at the time when app is reopened.