Firebase-js-sdk: Bug: auth.js throw error in Firefox Private mode

Created on 4 Apr 2018  路  13Comments  路  Source: firebase/firebase-js-sdk

  • Operating System version: MacOS 10.13.3
  • Firebase SDK version: 4.12.1
  • Firebase Product: auth
  • Browser: Firefox 59.0.2
  • Other information: Private mode

Firebase auth throw error on loading page in Firefox Private mode

image

I guess error comes from that piece

function Ti(a) {
  return new y(function (b, c) {
    var d = a.h.open("firebaseLocalStorageDb", 1);
    d.onerror = function (a) {
      c(Error(a.target.errorCode))
    };
    d.onupgradeneeded = function (a) {
      a = a.target.result;
      try {
        a.createObjectStore("firebaseLocalStorage", {
          keyPath: "fbase_key"
        })
      } catch (f) {
        c(f)
      }
    };
    d.onsuccess = function (a) {
      b(a.target.result)
    }
  })
}
auth

Most helpful comment

The fix is ready but not yet in the repo. For now, you can downgrade to 4.11.x. We'll try to get this in asap.

All 13 comments

@IvanKalinin Could you please provide the code snippet of how you use firebase Auth and the flow to trigger this error?

@wti806 I believe this bug happens anytime you initialize Firebase in Firefox private browsing mode. In case it's helpful, though, I created a small test app to reproduce it.

  1. Open Firefox in Private browsing mode
  2. Visit https://kmjennison.github.io/firebase-idb-debug/
  3. Click "Initialize Firebase". You should see the error.

I included a modified Firebase that logs the error to console. If you repeat the above but click "Initialize modified Firebase", you should see:
InvalidStateError: A mutation operation was attempted on a database that did not allow mutations.

It's expected that IndexedDB won't work in Firefox privacy mode, so it looks like Firebase isn't properly detecting the lack of IDB support.

Anyone know how we can catch this error to alert to users?
Any updates on this?

The fix is ready but not yet in the repo. For now, you can downgrade to 4.11.x. We'll try to get this in asap.

A warning on downgrading to 4.11.x: it will require all users to re-authenticate, because the old storage values in localStorage are deleted when upgrading to 4.12.0. Then, if a user re-authenticates, and later logs out, their credentials will still exist in indexedDB鈥攎eaning upgrading to >4.11.x will automatically log them (or whoever's using the computer) back in. Downgrading doesn't look like a valid option.

I need a small confirmation.
So, if Firefox continues disabling IndexedDB in Private Mode, then Firebase auth would never be able to work in FF's Private Mode? Or is there a plan where Firebase would stop using IndexedDB in auth?

This seems to be a big issue for us right now. Apologise if wrong place to ask, but highly appreciate a brief explanation on the question above. Thanks!

We modified the code to fallback to localStorage when indexedDB is not available/accessible/functional. If localStorage is not accessible/available, we fallback to in memory storage.

馃檹 @bojeil-google
Thanks, we now have some hope.
So, these changes will reflect on the next release?

The release should be out on Thursday I believe. You can test the changes from canary. We apologize for the delay. We had some build issues the past week which blocked this release.

Okay, it's coming quite soon. Thanks.
One more quick question, what do you mean by testing in canary?
Is there an experimental version of Firebase we can use or Chrome's Canary?

I meant firebase@canary on NPM

Any update on this? Looks like auth.js is still broke on Firefox/Private:
image

Edit: Nevermind, I've updated to 5.0.4 and the issue is fixed...

This has been fixed and confirmed a while back.

Was this page helpful?
0 / 5 - 0 ratings