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

一个人想着一个人 提交于 2020-06-27 02:17:06

问题


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 on offline mode. However, if the application stays open in the background mode on re-opening it always tells 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.

Is there any different way of doing? I already looked at StackOverflow, Github, all google and I can't find any 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, like: -detect the change to the background and unsubscribe and re-subscribe if any change to the foreground.

Do you know in any other way of doing?


回答1:


That error I solved with:

    window.onerror = function(error) {
  if (error.indexOf("An internal error was encountered in the Indexed Database server") >= 0) {
    // Refresh the page to restore IndexedDb to a working state.
    window.location.reload();
  }
};

and about how to observe the state changes of background and foreground:

import { Platform } from 'ionic-angular';

@Component({
  template: `OK`
})

constructor(public platform: Platform) {

    platform.ready().then(() => {

      if (platform.is('cordova')){

        //Subscribe on pause
        this.platform.pause.subscribe(() => {
          //Hello pause
        });

        //Subscribe on resume
        this.platform.resume.subscribe(() => {
          window['paused'] = 0;
        });
       }
    });
}

I hope they serve you greetings.



来源:https://stackoverflow.com/questions/57443547/ionic-4-ios-firestore-internal-assertion-failed-asyncqueue-is-already-failed-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!