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

Firestore read not working for multi-page app in Safari private mode #7940

Closed
gunnarmein-ts opened this issue Jan 11, 2024 · 17 comments
Closed

Comments

@gunnarmein-ts
Copy link

Operating System

macOS 14.2

Browser Version

Safari 17.2.1

Firebase SDK Version

10.1

Firebase SDK Product:

Firestore

Describe your project's tooling

HTML/TypeScript app built with esbuild

Describe the problem

We have a document shell (index.html) and the actual document editor (document.html). Both initialize Firebase auth. We use signingWithPopup and our subdomain is our config auth domain. We can sign in successfully on index.html, but transitioning to document.html, the first call to getDoc() will not resolve until some ridiculous time later (I noticed it had resolved after I took the dogs for a walk). Meanwhile, a couple of promises were rejected:

[Warning] [2024-01-11T16:45:26.104Z] @firebase/app: – "Firebase: Error thrown when reading from IndexedDB. Original error: Error looking up record in object store by key range. (app/idb-get)." (document-bundle.js, line 142)
[Error] Unhandled Promise Rejection: AbortError: AbortError
error (document-bundle.js:1541)

image

and another one, both by the heartbeat service.

This works fine in Chrome. I cannot say whether it works in Safari. It becomes an issue because when Safari is automated (by Selenium in our case), it will only launch in a private window now, making all of our Safari tests fail.

Steps and code to reproduce issue

  • Write firebase app with 2 html pages
  • Open Safari private window
  • sign in on page one
  • load page 2
  • read doc from firestore db (the doc is not protected by auth or identity, it is marked "allow read;" in firestore.rules)
    -> hangs for a long time (deadlock?)
@gunnarmein-ts gunnarmein-ts added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Jan 11, 2024
@gunnarmein-ts
Copy link
Author

Could be related to #7890

@gunnarmein-ts
Copy link
Author

Completely giving up on persistentLocalCache (not just the persistentMultipleTabManager) for Safari seems to be a workaround.

@jbalidiong jbalidiong added needs-attention and removed new A new issue that hasn't be categoirzed as question, bug or feature request labels Jan 11, 2024
@dconeybe
Copy link
Contributor

Drive-by comment: Note that IndexedDb is typically not available in "private" or "incognito" tabs. So Firestore persistence won't work in such an environment. That being said, it should gracefully fall back to memory persistence (i.e. the default persistence mode) so there may be a bug here.

@diginikkari
Copy link

Getting this error also in normal mode (non private) with Safari (Version 17.2.1 (19617.1.17.11.12)). Firebase version 10.7.1.

@gunnarmein-ts
Copy link
Author

Getting this error also in normal mode (non private) with Safari (Version 17.2.1 (19617.1.17.11.12)). Firebase version 10.7.1.

I find that once this error happens, I need to shut Safari down or nothing - private or public - will work again.

@cherylEnkidu
Copy link
Contributor

Hi @gunnarmein-ts and @diginikkari ,

I try to reproduce the issue with the same MacOS, Safari, Firebase version but did not succeed. If you are still experiencing this issue, could you please provide a minimum repo app?

@gunnarmein-ts
Copy link
Author

cherylEnkidu I can do it this week, but not today. Thanks for looking into it!

@google-oss-bot
Copy link
Contributor

Hey @gunnarmein-ts. 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!

@google-oss-bot
Copy link
Contributor

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

@gunnarmein-ts 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.

@jmw11x
Copy link

jmw11x commented Feb 21, 2024

This issue needs re-opened. This following problem is happening using firebase-firestore modular javascript sdk and also the namespaced sdk.. It DOES NOT matter if I am using a private window or not. I am getting same errors as OP

I understand I am new to this thread but I have the same problem that is not fixable. I get the following error

[Error] Fetch API cannot load https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?gsessionid=8qcyJFQ6JAVdz74fZdpieIMa4LoN6nrDCcTr1DznZAU&VER=8&database=projects%2Frexialoserviceseasypm%2Fdatabases%2F(default)&RID=rpc&SID=nlKk0dvZJQ2TqC02Z3UxQQ&AID=22&CI=0&TYPE=xmlhttp&zx=ot7ybir2ifjb&t=1 due to access control checks.
(anonymous function) (firebase-firestore.js:1:33605)
(anonymous function) (firebase-firestore.js:1:49999)
ic (firebase-firestore.js:1:21211)
Md (firebase-firestore.js:1:40296)
(anonymous function) (firebase-firestore.js:1:51867)
ub (firebase-firestore.js:1:17060)

when navigating to any different page that data is loaded into and then NO imports are recognized and everything within the app completely breaks to 0!!!! Where only hosting works functions, auth, database, firestore BROKEN.

Interesting other things noticed and full description of error (NEED SOLUTION)

If I go from page A => Page B where page B reads db data it will work and show onSnapshot. Going away to page a and back to page b its all gone and error is shown on page A. Going back to page B (or anywhere) yields broken application.

If I go from Page A -> page B and refresh page it will load cached data. (Before namespaced-> modular upgrade no cache loaded at all)

so Somewhere on page B the following occurs


const q = query(collection(db, path))

const project_data = onSnapshot(
    q,
    { includeMetadataChanges: true },//broken without too
    (snapshot) => {
        snapshot.docChanges().forEach((change) => {
            // get data after change.type do stuff with it

        })
    })

Page A has no db reads but needs ref to initializeFirestore for writes. Writes do not cause this issue only reads.

@cherylEnkidu
Copy link
Contributor

Hi @jmw11x ,

Sorry for your experience :(, I cannot successfully reproduce this issue on my side. Given your issue is not related to this ticket, can you open a new github ticket and provide us a minimum repo? Also In your repo app, can you only use Firestore without functions, auth, database?

@jmw11x
Copy link

jmw11x commented Feb 23, 2024

Sure thing I can if needed, I am also working with support team on ticket I have MCVE for them I can have it added here if needed.

Using modular javascript sdk..

importing from

https://www.gstatic.com/firebasejs/10.8.0/firebase-app.js

&

https://www.gstatic.com/firebasejs/10.8.0/firebase-firestore.js

I have the mcve with auth. I will make a branch / other section without it too.

Please note that this is related to this ticket/OP. I have the same problem except it is not in private mode it is in safari in general with SAME error / behavior produced.

Problem Description: Without persistant cache I get no data at all on safari from onSnaphot functions. With persistant cache I get behavior op describes and it breaks the entire application and auth and all other features no longer work besides hosting.

@cherylEnkidu
Copy link
Contributor

Thank you for your repo! Can you also pass me the support ticket id? I will follow up with the support team.

@jmw11x
Copy link

jmw11x commented Feb 23, 2024

Case #: 10271607
New case #: 10272357 (Other case team unhelpful created new case with complaint)

Repo: https://github.com/jmw11x/FirebaseFirestore-Case-10271607/tree/main

@jmw11x
Copy link

jmw11x commented Feb 26, 2024

Thank you for your repo! Can you also pass me the support ticket id? I will follow up with the support team.

Hello and thanks for the help,

I added an update today on this repo with cache enabled. You can see it now. It was not working under any settings on safari on friday and today it works without cache. The same problem is still occurring with cache as this thread and my op states with a change noticed. It does not break the application but no data loads. If I go to page without cache and back to cache it loads but if i go back home and back to cache gone again. Please look into this issue and fix it as it appears a fix was applied to safari in general over the weekend/this morning.

Error produced when data does not load : Unhandled Promise Rejection: UnknownError: Error looking up record in object store by key range (This error will result in crash of everything otherwise will only not load data when navigate page a -> page b -> page a)

the file is in Users/cache.html and easiest way is to go to root /index.html and navigate the buttons to and from the pages. The errors will present themselves as described above. Thanks again

NEW update. Safari down completely again at least it will appear to be so. Looks like when cache error happens it crashes everything on firebase firestore (not every time but if you keep causing it / leave it open it will) until you completely clear out cache on browser and shut down the process on computer.

@cherylEnkidu
Copy link
Contributor

@jmw11x

Could you please open a new github issue and mention me in the new issue? For the description, you can just copy and paste what you have here.

Having a new ticket will help us better tracking this specific issue, thank you so much for your help :)

@firebase firebase locked and limited conversation to collaborators Mar 10, 2024
@cherylEnkidu
Copy link
Contributor

The issue is been tracked here: #8081

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants