-
Notifications
You must be signed in to change notification settings - Fork 928
IOS Background reopen: @firebase/firestore: Firestore (7.6.2): FIRESTORE (7.6.2) INTERNAL ASSERTION FAILED: AsyncQueue is already failed: transaction@[native code] #2581
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
Comments
Note: this behaviour has been seen by others as well: https://stackoverflow.com/questions/57443547/ionic-4-ios-firestore-internal-assertion-failed-asyncqueue-is-already-failed-a |
Hi @Sroose thanks for reporting this issue. While I'm trying to reproduce this on my end, it would be great if you can provide a working repro that we can run locally to speed up the investigation. Thanks! |
@Sroose We have seen similar issues with our iOS SDK. Essentially, what can happen is that iOS locks the file system when an app is backgrounded. If the database is accessed when the file system is locked, the operation will fail. We already retry transactions when they fail (
In the Web SDK, logging can be turned on via setLogLevel(). |
Hello, I have the same issue. My app has the following features: it's a PWA, using Framework7 and using Firebase for Auth and DB (Firestore). When I pin it to my dashboard on iOS, if I open the app, then switch to another app, the switch back to it, Firestore crashes with the following error: Some of my observations:
I already be involved in the following threads, but they have not corrected my issue:
I decided to reproduce the bug with the smallest app I could. Simple PWA / Vue.js / Vuex / Firestore / Vuexfire -> RANDOMLY FAIL Framework7 PWA / Vue.js / Vuex / Firestore / Vuexfire -> FAIL Since I sometimes observes the bug in the first one, it's probably not relative to Framework7. It's possible that Framework7 make the app bigger, so iOS wait less time before killing some of the parts. |
@Pitouli Thanks for the detailed response! #1670 is an iOS bug that we cannot work around. #2232 should have been addressed and resolve issues for apps that are in the foreground. I suspect that you are also seeing issues with a locked file system on iOS. If you have the original error message (the part after "AsyncQueue is already failed") that would help us narrow it down. In general, I think we can probably be smarter about our transaction retries and delay retries until the app comes back in the foreground. I will talk to my team about this. |
FYI, we have added a piece of code that detects when the app will go to background and at that point unsubscribe from the Firestore objects, and resubscribe when coming back from background. Note that I do not consider this a solution but it might be helpful in further analyses and also be useful to others:
|
@schmidt-sebastian : a screnshot and a copy paste
|
Is there a separate ticket for handling this issue on other platforms? I've had it pop up in production on Windows 10 using Chrome (Firestore 7.6.2). |
We are affected as well and found this issue in stackoverflow. |
We had a discussion internally and found a potential strategy to mitigate these issue. This will require some thought and an implementation plan. Please do bear with us as we see this through. As a workaround, I would recommend not using the SDK while the app is in the background. You may also have to call |
Hi @schmidt-sebastian We see there is another error which seems to crash the app on Android and block part of the code on iOS. I've logged this separately as #2610 as I'm not sure if this is really related. |
Extra note on the disableNetwork() suggestion: after some debugging, it seems the enableNetwork() does not always work. Often, it does not do anything.
Nor the success or error messages are printed in these situations. |
@Sroose We are still figuring out how to address this properly, as this might involve a breaking API change since me may now have to return errors for operations that we previously decided simply could not fail. |
Suffering from the same error, Firestore stops working & only solution is to restart the PWA. FYI: Also showed up on iOS 11.3, not only iOS 13. My details: Firebase SDK version: 7.8.1 & 7.9.0 Error
|
ONLY A WORKAROUND
That way, in case the error appears, the app gets reloaded on the current page and Firebase works again. The user - in my case - barely realizes that the app was reloaded, because the error appears usually (or always) when a PWA is opened again after a while. Looks something like this in my Vue.js app: const fatalErrorsRegExp = [
'INTERNAL ASSERTION FAILED: AsyncQueue is already failed'
]
for (const fatalErrorRegExp of fatalErrorsRegExp) {
const re = new RegExp(fatalErrorRegExp)
const isMatch = re.test(error) || re.test(error.message)
if (isMatch && window.location.hash !== '#retry') {
// mark the page to don't trigger reload infinitely
window.location.hash = '#retry'
window.location.reload(true)
return
}
} BTW: Also works well with general PWA chunk-errors (due to renamed chunks after a new release), in case you also get them in your app ;) |
Also having an issue where firebase stops working after app is coming out of sleep. Thought I should post my logs here as well. I am running our app on an ipad and the xcode target logs are as follows:
|
Hey - any more news on this? Getting this often as well - firebase stops working when ios app resumes from background (in my case in ionic/capacitor setup). Is there a fix for this in the works somewhere or do we need to work around? Thanks! |
@joplaete for now, just another workaround that is working for me is to use the ionic backgroundmode plugin. It keeps the app awake in background and when screen is off. For android it works well. But beware for ios -apple rejects it because the plugin references 'audio' for it's reason to keep the app from sleeping. So you'd need to justify why the plugin in being used (the app basically needs audio feature). |
I am working on this as part of #2755. |
Describe your environment
Describe the problem
Steps to reproduce:
Ionic cordova app using Firestore. Works very well under normal situations.
When opening through notification and it's a cold app start, also no problems.
But only when the app is in the background and reopened through a notification tap, firebase will throw a lot of errors and stop working:
@firebase/firestore: Firestore (7.6.2): FIRESTORE (7.6.2) INTERNAL ASSERTION FAILED: AsyncQueue is already failed: transaction@[native code]
Relevant Code:
(Cannot reproduce this on stackblitz as it is on device.)
Simplified use:
The text was updated successfully, but these errors were encountered: