Firebase-js-sdk: Firestore error on page leave for Safari

Created on 30 Aug 2020  路  9Comments  路  Source: firebase/firebase-js-sdk

Describe your environment

  • Operating System version: error found on macOS 10.15.6 and iOS 13
  • Browser version: Safari 13.1.2
  • Firebase SDK version: 7.19.1
  • Firebase Product: firestore

Describe the problem/Steps to reproduce:

To reproduce this error, run any code involving the firebase-firestore.js on Safari and change the webpage (for my case, go to https://www.worldwideprayer.cf and refresh the page). If no code involving Firestore is run the error does not happen (var db = firebase.firestore() is fine but if the variable db is used to read or write then the error will appear when the webpage changes). This doesn't happen on any other browser except Safari.

This is the error as shown in the console:
XMLHttpRequest cannot load https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?database=projects%2Fprayerapp1%2Fdatabases%2F(default)&gsessionid=SKZap0Rtq8Op1KsxuSxGuZS9a5ewmvB3txB7wfsYWJQ&VER=8&RID=rpc&SID=IBee8U_80DZsnyR1cGAcDg&CI=0&AID=47&TYPE=xmlhttp&zx=2te0p094z0a0&t=2 due to access control checks.
Screen Shot 2020-08-30 at 1 51 42 PM

I found that the error is due to files constantly trying to be loaded by firebase-firestore.js and when the page is changed, there is always at least one file not completely loaded yet:
Screen Shot 2020-08-30 at 1 54 04 PM

On other browsers the files load instantly when a read or write operation is performed and they only load once, instead of starting again after the previous load is finished.

This normally wouldn't be a problem but I am running code when the page is changed and this is preventing that code from executing.

Relevant Code:

Here is code that will reproduce the error when run on Safari:
https://firebase-issue-sandbox-wdcffw.stackblitz.io

Any read/write operation seems to be all that is needed to start the loading of files in the background, the loading of which will be cut off on page change and the error will occur.

A minimal sample app can be found here: https://www.worldwideprayer.cf/test.html Open on Safari, open the console, make sure to click "Preserve Log" and refresh the page to see the error.
Here is the code itself:

js/test.js:

var db = firebase.firestore();

db.collection("counter").doc("meditation_count")
.onSnapshot(function (doc) {
console.log("Current data: ", doc.data());
});

test.html:

<script src="https://www.gstatic.com/firebasejs/7.14.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.14.1/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.14.1/firebase-storage.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.14.1/firebase-auth.js"></script>

<script>
    // Your web app's Firebase configuration
    var firebaseConfig = {
        apiKey: "AIzaSyBZI0rjKX_Jyx1LogVuwrLyJgYiZisZ1z4",
        authDomain: "prayerapp1.firebaseapp.com",
        databaseURL: "https://prayerapp1.firebaseio.com",
        projectId: "prayerapp1",
        storageBucket: "prayerapp1.appspot.com",
        messagingSenderId: "364802336788",
        appId: "1:364802336788:web:b730c2fdbcd67a2f63df01"
    };
    // Initialize Firebase
    firebase.initializeApp(firebaseConfig);
</script>

<title> Test </title>

');

firestore closed-by-bot internal-bug-filed needs-info no-recent-activity

All 9 comments

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

Hi @jimjimmitythejim! I'd like to look into your issue but I need some more information.

  1. Could you please update the original comment with information from the new issue template? Just create a new issue in this repository and copy the template into your original comment.
  2. Is it possible to provide a minimal sample app to reproduce the issue?

Note that the "files constantly trying to be loaded by firebase-firestore.js" that you mention is expected behavior. It is a "hanging GET" request that waits for responses from the server to update listeners, providing a sort of bi-directional socket between the client and server.

In the meantime, I'll look into the "XMLHttpRequest cannot load" error.

Hi dconeybe, thank you so much for the help. I updated my original comment. I really appreciate it.

For some reason the test.html code is not rendering properly in my original comment but going to https://www.worldwideprayer.cf/test.html and going to the source code is all it is.

Note: I have filed a bug in our internal bug system: b/167265358. I will update this issue as that ticket progresses.

@dconeybe I have been getting the same issues, I'm assuming you're trying to reload the page after this internal error.
Because when the page reloads, it does not have the search params.

My page goes from '/some-page?foo=bar' to '/some-page' after this error occurs on Safari 13.1.1 (15609.2.9.1.2)

@nihalanisumit There are no "internal errors" occurring. When I press the "Refresh" button on https://www.worldwideprayer.cf in Safari on my Mac then the hanging GET request fails with the "XMLHttpRequest cannot load https://firestore.googleapis.com/... due to access control checks." error. I believe that @jimjimmitythejim is asking for this hanging GET to instead close successfully. Do you have concrete steps to reproduce that you could provide? Or a sample app I could use to reproduce?

@dconeybe really sorry I did something stupid, yes the page was getting refreshed. In react I was submitting a form and forgot to do event.preventDefault() which caused the page to reload and removed search params. So i was indirectly refreshing the page and was getting this error.


Hey @jimjimmitythejim. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!


Since there haven't been any recent updates here, I am going to close this issue.

@jimjimmitythejim if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

Was this page helpful?
0 / 5 - 0 ratings