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

Compat Mode: Checking for "sessionStorage" reference crashes the app when chrome has "block third-party cookies" enabled #5913

Closed
rosostolato opened this issue Jan 21, 2022 · 9 comments

Comments

@rosostolato
Copy link

rosostolato commented Jan 21, 2022

The same as #5618 but it's still broken for compat mode.

If customers enable the "block third-party cookies" feature under chrome settings, Chrome will throw an exception when you try to access the sessionStorage reference in window. To solve that, we should add a try/catch for all lines that reference sessionStorage and not only check if it's null.

if (!win?.sessionStorage) {

DOMException: Failed to read the 'sessionStorage' property from 'Window': Access is denied for this document.
Unhandled Promise rejection: The user denied permission to access the database. ; Zone: <root> ; Task: Promise.then ; Value: The user denied permission to access the database.
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@rosostolato rosostolato reopened this Jan 22, 2022
@rosostolato rosostolato changed the title Checking for "sessionStorage" reference crashes the app when chrome has "block third-party cookies" enabled Compat Mode: Checking for "sessionStorage" reference crashes the app when chrome has "block third-party cookies" enabled Jan 22, 2022
@hsubox76
Copy link
Contributor

Seems to be used in Auth and Database

@sam-gc
Copy link
Contributor

sam-gc commented Jan 24, 2022

That PR I just linked should fix it in Auth, but I'll make sure to leave this open for database as well. @rosostolato I only see the issue when all cookies are disabled, not just third-party cookies. Which version of Chrome are you on?

@rosostolato
Copy link
Author

@sam-gc I don't remember the version of Chrome I was using but I have just tested it now with the latest one and it seems it's not crashing anymore. I still see the database access error, but it's not breaking the app.

@sam-gc
Copy link
Contributor

sam-gc commented Jan 25, 2022

@rosostolato no problem, like I said it still happens for me when all cookies are disabled so there's at least an easy way to reproduce it 👍

@sam-gc
Copy link
Contributor

sam-gc commented Jan 25, 2022

I'm going to remove the api:auth tag for now; the fix for auth should be in the next release or the one after. We will keep this issue open for database

@sam-gc sam-gc removed the api: auth label Jan 25, 2022
@wisonye
Copy link

wisonye commented Mar 15, 2022

That PR I just linked should fix it in Auth, but I'll make sure to leave this open for database as well. @rosostolato I only see the issue when all cookies are disabled, not just third-party cookies. Which version of Chrome are you on?

Hi there, actually, I still got the same error after installing the latest firebase(^9.6.8), and I've already confirmed that install "@firebase/auth-compat" on "0.2.9" version (search in package-lock.json).

This error still will happen when running the Firebase app in an iframe (when window.sessionStoarge is called inside the firebase source code. I think _getSelfWindow()?.sessionStorage ???).

But finally, I realize that we don't need to save the token across sessions (or cross-browser tabs), so I changed to inMemoryPersistence which can save my life, as it seems there is NO WAY to avoid that error when the Block third-party flag is enabled, plz correct me if I'm wrong:)

@maneesht
Copy link
Contributor

maneesht commented Sep 7, 2022

Removing database as we surround our sessionStorage initialization around a try/catch

@sam-gc
Copy link
Contributor

sam-gc commented Sep 8, 2022

I can't reproduce this in Auth. With third party cookies totally disabled compat still works. I'm going to go ahead and close this out now. Please reopen if you're still seeing this issue with the latest version of Auth.

@sam-gc sam-gc closed this as completed Sep 8, 2022
@firebase firebase locked and limited conversation to collaborators Oct 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants