Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Messaging in Firefox private mode (IndexedDb) #5868

Closed
vandres opened this issue Jan 7, 2022 · 6 comments · Fixed by #5957
Closed

Messaging in Firefox private mode (IndexedDb) #5868

vandres opened this issue Jan 7, 2022 · 6 comments · Fixed by #5957

Comments

@vandres
Copy link

vandres commented Jan 7, 2022

[REQUIRED] Describe your environment

  • Operating System version: MacOS Monterey
  • Browser version: Firefox 95.0.2 (and Tor)
  • Firebase SDK version: 9.1.6 (modular)
  • Firebase Product: messaging

[REQUIRED] Describe the problem

We recently upgraded our Angular app to Firebase v9 Modular. After some DNS changes we tested our app with Tor and were presented with a white page. We then reproduced the issue with Firefox private mode. Normal Firefox sessions work. When allowing browser history in Firefox private mode, it also works.

When using the private mode, we see the following error: Unhandled Promise rejection: A mutation operation was attempted on a database that did not allow mutations. ; Zone: <root> ; Task: Promise.then ; Value: A mutation operation was attempted on a database that did not allow mutations.

I tried disabling IndexedDb then for the whole app, but the problem lies within in the initialization of the messaging module.

async function isWindowSupported() {
    // firebase-js-sdk/issues/2393 reveals that idb#open in Safari iframe and Firefox private browsing
    // might be prohibited to run. In these contexts, an error would be thrown during the messaging
    // instantiating phase, informing the developers to import/call isSupported for special handling.
    return (typeof window !== 'undefined' &&
        isIndexedDBAvailable() &&
        (await validateIndexedDBOpenable()) &&
        areCookiesEnabled() &&
        'serviceWorker' in navigator &&
        'PushManager' in window &&
        'Notification' in window &&
        'fetch' in window &&
        ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&
        PushSubscription.prototype.hasOwnProperty('getKey'));
}

Steps to reproduce:

Any app using AngularFire with the messaging module should be affected: https://github.com/angular/angularfire

@simeon9696
Copy link

I don't think messaging is supposed to work in private mode? It definitely doesn't work in incognito on Chrome.

@rizafran rizafran added the v9 label Jan 7, 2022
@dconeybe
Copy link
Contributor

dconeybe commented Jan 7, 2022

Drive-by comment: We had the same issue in Firestore: #5377. Firefox private browsing does not (currently) support IndexedDb and Firefox has an open feature request to address this: https://bugzilla.mozilla.org/show_bug.cgi?id=1639542.

You can configure Firefox to allow IndexedDb in private browsing mode to confirm that IndexedDb is indeed the root cause: #5377 (comment). Obviously, this isn't really a viable solution for your users though, just a means of confirming the root cause.

@aydun1
Copy link

aydun1 commented Jan 24, 2022

I'd just like to say that I am seeing the same error using Firebase 9.6.4.

I'm using Firebase in an Angular app which fails to load in Firefox private browsing mode when importing the messaging module.

I can confirm that enabling DB persistence in Firefox private browsing mode does resolve the error. But yeah, obviously not viable.

@hsubox76
Copy link
Contributor

Messaging is not supported in environments that don't allow indexedDB. In order to prevent the app crashing if it's run in one of those environments, you can use the isSupported() method and only initialize messaging if it resolves with true, but there isn't a way to make messaging work in those environments.

@vandres
Copy link
Author

vandres commented Jan 24, 2022

@hsubox76 Calling isSupported() actually creates this problem, because the Promise gets rejected in that environments. The rejection is not handled.

I checked the v9 compat version meanwhile, there the code doesn't use a Promise and that's why that version works. But I need to use the modular version for other reasons.

@hsubox76
Copy link
Contributor

I see, the compat code actually is missing this check and that's incorrect, but the modular code should be wrapping the await in a try/catch so that's also incorrect. Thanks for bringing this up, will look into fixing both.

@firebase firebase locked and limited conversation to collaborators Mar 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.