firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.83k stars 892 forks source link

Uncaught exception in verifyNotFailed (Javascript, mostly iOS 12.2) #1733

Closed momander closed 5 years ago

momander commented 5 years ago

Environment

Describe the problem

About a quarter of my website visitors using iOS 12.2 and Safari 12.1 get this error, or about 400-500 out of 1,700 visitors. I have not heard any reports of failing functionality yet, but they are getting uncaught Javascript exceptions which are tracked by Google Analytics.

Steps to reproduce:

Sorry, I don't have access to an iOS 12.2 device. I only see the hundreds upon hundreds of these errors in the log.

Relevant Code:

When the exception occurs, the Javascript call stack is: documentVisibilityHandler() which called enqueueAndForget() which called enqueue() which called verifyNotFailed() where the exception occurred

Sometimes (less often) the call stack is: handleDelayElapsed() which called enqueueAndForget() which called enqueue() which called verifyNotFailed() where the exception occurred

Sometimes (less often) the call stack is: windowUnloadHandler which called enqueueAndForget() which called enqueue() which called verifyNotFailed() where the exception occurred

Other clients:

This error also occurs very occasionally in Windows and Android clients. When this happens, there is a better error message:

Error: FIRESTORE (5.9.4) INTERNAL ASSERTION FAILED: AsyncQueue is already failed

or

Error: FIRESTORE (5.9.4) INTERNAL ASSERTION FAILED: AsyncQueue is already failed: The transaction was aborted, so the request cannot be fulfilled.

My code to log Javascript errors in Google Analytics:

window.onerror = function(message, source, lineno, colno, error) {
  if (error) message = error.stack;
  if (!location.host.startsWith('localhost')) {
    ga('send', 'event', 'window.onerror', message, navigator.userAgent);
  }
}

My Firebase configuration:

let db = firebase.firestore();
db.enablePersistence({experimentalTabSynchronization:true})
google-oss-bot commented 5 years ago

I found a few problems with this issue:

momander commented 5 years ago

Oh, one more data point: most of my website visitors do not trigger code that reads or writes to Firestore. So most of the visitors who trigger the verifyNotFailed exception only run this code in their browsers:

var firebaseConfig = {
  ...
};
firebase.initializeApp(firebaseConfig);
let db = firebase.firestore();
db.enablePersistence({experimentalTabSynchronization:true});
mikelehen commented 5 years ago

EDIT: Fixed link to github issue.

Thanks for the report. This seems to be a regression in iOS 12.2 which is being tracked by https://github.com/firebase/firebase-js-sdk/issues/1670 and https://bugs.webkit.org/show_bug.cgi?id=197050. The only workaround for now is to not enable persistence.

var-const commented 5 years ago

Sorry to hear about the problems you're running into. The issues described appear very similar to 2 problems that were reported recently:

  1. Android failure with AsyncQueue is already failed: The transaction was aborted, so the request cannot be fulfilled. sounds very similar #1642. Interesting that it also happens on Windows in your case -- how often are Windows devices affected, compared to Android?
  2. The failure that happens specifically on iOS 12.2 is likely #1670.

Note that these two are separate issues with different causes, but they are triggered in a very similar manner -- sending the app to the background may result in a failure. This seems consistent with the way only some of the users experience the issue.

Can you please provide some additional info?

  1. Logs would be very helpful (just in case, firebase.firestore.setLogLevel('debug')). If they contain any sensitive data, feel free to send them over email to varconst at google.com. Especially on iOS, I hope logs would help to determine whether the issue here is indeed #1670.
  2. Any additional information on what triggers the exceptions would be useful. In particular, my suspicion would be that sending the app to background is triggering the issue, would be very helpful if you could confirm.
momander commented 5 years ago

My apologies; I don't have access to either an iOS 12.2 device or a Windows machine. I tried to reproduce the error on a virtual Windows machine on lambdatest.com, but was not able to.