Ionic 4 IOS FIRESTORE INTERNAL ASSERTION FAILED: AsyncQueue is already failed: An internal error was encountered in the Indexed Database server

Hello to the entire Ionic community, I am developing an Ionic application, I am using Firestore as a database, using offline mode.

import {AngularFirestoreModule} from ‘@ angular / fire / Firestore’;
AngularFirestoreModule.enablePersistence (),

When I open the application everything works very well, even offline mode, if I remove the internet, the application continues to work and when I connect the application to the internet, sends the changes to de DB made in offline mode correctly.

My problem is that, if the application stays open in background mode when I re-opening it always tells me this error:

FIRESTORE (6.2.4) INTERNAL ASSERTION FAILED: AsyncQueue is already failed: An internal error was encountered in the Indexed Database server.

And I can no longer navigate anywhere in the application because I have the condition that the subscription is alive until the component is destroyed (that happens when I change the page)
takeUntil (componentDestroyed (this)):

I get the following error:

“1 errors occurred during unsubscription: 1) Error: FIRESTORE (6.2.4) INTERNAL ASSERTION FAILED: AsyncQueue is already failed: An internal error was encountered in the Indexed Database server”

And the full application stops working and it is very annoying to have to close it and reopen

So, folks, I come to you to see if there is any different way this way, I already looked at StackOverflow, Github, all google and I can’t find the solution.
What I have seen the other applications like Netflix, HBO, etc. do. is that when you reopen the application does not start exactly where it stayed, it warns you that it is loading, and when it finishes loading it leaves you very close to where you were before leaving the application without activity. I imagine it has a background and foreground change detector and a function for each event.

I was thinking that with ionic cycles I could solve that problem:

Detect the change to the background and unsubscribe and re-subscribe if I detect the change to the foreground.

Do you know in any way to do that?

Do you have any other solution?

I very much appreciate your attention and collaboration

I received the answer to this question by Stack Overflow:
https://stackoverflow.com/questions/57443547/ionic-4-ios-firestore-internal-assertion-failed-asyncqueue-is-already-failed-a

Nice! I was puzzled by this bug today, iOS 12.4.5 on iPhone6. I’m just a little curious to where to put that window.onerror(…) you refer to in Stack overflow?

Tried putting it inside app.component.ts’ constructor() and at least Code does not warn me on anything, but I haven’t been able to reproduce the error yet; it’s a bit random it seems. Is my constructor() placement a good place to put this reload-code?

BTW I’m on ionic 5 + capacitor but I think the structure is very much the same.