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
Firebase v.9 Firestore getDoc() causes Lighthouse to hang #5398
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
Hi @dconeybe. Thank you for looking into this. Here it is: https://github.com/maierson/fbselght It's built with If you install on Netlify it detects your nrwl project and provides defaults that work out of the box. You just need to set the app name |
I forgot to mention. You'll need an authenticated user in firebase and a |
Thanks for this! I'll be digging into this further tomorrow. |
@dconeybe any news on this one? Were you able to reproduce? |
@dconeybe Thank you for answering. I can confirm that const q = query(
collection(firestore, collectionPath),
orderBy("dateCreated", "desc"),
);
getDocs(q) This query works when importing from |
Btw I can't reopen this issue once you've closed it. Can you please reopen it? |
Reopening since |
@maierson Can you share your debug logs? I am not able to reproduce the described behavior with either getDoc:
'getDocs' shows similar logs for me. |
@schmidt-sebastian I have no meaningful logs because this is in production mode on netlify. Some pointers: I don't have it implemented in the repro but will try to do it once I have a moment to confirm. |
I see the same behavior for getDoc/getDocs (when I filter for a single doc in getDoc). Lighthouse passes for me, but it is a bit slow. When I open the console logs for Lighthouse I see that the documents are fetched right away, but Lighthouse continues its measurement. I am not able to make much progress here. If you think it might be worthwhile to talk this over, shoot me an email to mrschmidt(at)google.com. |
Yes correct. That's what I see too: docs load quickly but Lighthouse completes quite a lot later with the warning that the page loaded too slowly to finish within the allotted time. If I use the lite version it completes right away. It used to do that for |
I'm still experiencing this behavior in v9.8.4. Someone in #5402 mentioned that this possibly caused by where the auth persistence is placed, but there isn't much I can do about that unfortunately, as below is my initialization and persistence code in verbatim with options omitted. window.firebaseApp = initializeApp({ ... });
await getAuth(window.firebaseApp).setPersistence(browserLocalPersistence); I'm also able to log the uid in the code where I'm experiencing the block: export async function fetchProfile(uid: string): Promise<Profile | undefined> {
console.log('[fetchProfile]', uid);
const firestore = getFirestore(window.firebaseApp);
const cacheStore = useCacheStore();
const profileFromCache: IProfile | undefined = cacheStore.profileCache[uid];
console.log('[fetchProfile]', 'cache', profileFromCache);
if (!!profileFromCache) return new Profile(profileFromCache);
else {
console.log('[fetchProfile]', 'using firestore');
const docRef = doc(firestore, `/users/${uid}`) as DocumentReference<IProfile>
console.log('[fetchProfile]', 'ref', docRef);
const docSnap = await getDoc(docRef);
console.log('[fetchProfile]', 'snap', docSnap);
console.log('[fetchProfile]', 'snapExists', docSnap.exists());
const profileFromFirestore = docSnap.data();
console.log('[fetchProfile]', 'firestore', profileFromFirestore);
if (!!profileFromFirestore) return new Profile(profileFromFirestore);
else return undefined;
}
} Here's a screenshot of the console output for that code: Someone else on the #5402 thread mentioned this Rollup issue which also might be to blame since I'm currently using Vite and TS, though I'm not entirely sure of the relevance. Either way, any help would be greatly appreciated, cheers! |
I am able to reproduce the "The page loaded too slowly to finish within the time limit" warning message in lighthouse. Lighthouse is waiting for the watch stream to close, while the SDK keep it open for new requests that might come in. This should not affect web performance, as you noticed, the expected data has been received promptly. However, I am unable to reproduce the unresponsive |
Hey @maierson. 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. @maierson 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. |
Describe your environment
Describe the problem
We are porting our application to v.9 while at the same time attempting to improve the Lighthouse score. When loading a User object from Firestore for the first time we have tried in two ways:
1. gRpc (sdk) installed via npm.
This would be our preferred way to use it for obvious reasons but it appears to hang Lighthouse until it times out. Here is a snapshot of the result:
We are aware of the firestore gRpc bootstrapping initial time but this usually takes about 3 seconds max (plus the user data is already received before that so that's not the issue) and Lighthouse hangs for a lot longer before giving up. It seems as if a connection is not closed properly to allow Lighthouse to complete. Not sure if this is a socket issue - I'm not deeply familiar with the workings of gRpc.
2. REST api with fetch and authentication token.
This call completes in sub-second time and allows Lighthouse to close down without errors.
Steps to reproduce:
Retrieve any document on first page load from Firestore via the
getDoc(doc(...))
call.We have also tried using
reactfire
but the issue is the same.The text was updated successfully, but these errors were encountered: