firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.86k stars 895 forks source link

30 seconds hang in onSnapshot #8510

Closed justinmann closed 2 months ago

justinmann commented 2 months ago

Operating System

Android, iOS

Environment (if applicable)

mobile web

Firebase SDK Version

10.13.2

Firebase SDK Product(s)

Firestore, Functions

Project Tooling

React + NextJS

You see the time lag between the two log statements from firestore. I did not enable AppCheck on web.

_app-7db23c94cc153c11.js:1983 [LOCALE] {"languageTag":"en-US","languageCode":"en","textDirection":"ltr","digitGroupingSeparator":",","decimalSeparator":".","measurementSystem":null,"currencyCode":null,"currencySymbol":null,"regionCode":"US","temperatureUnit":"fahrenheit"} _app-7db23c94cc153c11.js:2013 MIXPANEL PEOPLE REQUEST (QUEUED, PENDING IDENTIFY): _app-7db23c94cc153c11.js:2013 Object _app-7db23c94cc153c11.js:5857 [FIREBASE] 2024-09-22T05:24:31.477Z initialize _app-7db23c94cc153c11.js:5857 [FIREBASE] 2024-09-22T05:24:31.488Z getAuth _app-7db23c94cc153c11.js:5857 [FIREBASE] 2024-09-22T05:24:31.490Z getFirestore _app-7db23c94cc153c11.js:5857 [FIREBASE] 2024-09-22T05:24:31.491Z getFunctions _app-7db23c94cc153c11.js:5857 [FIREBASE] 2024-09-22T05:24:31.492Z httpsCallable _app-7db23c94cc153c11.js:5857 [FIRESTORE] 2024-09-22T05:24:31.708Z undefined trackDocs ["userPrivate",["TjcBmypHVuPIVy6zcPlgUhttJs72","userConversation"]] _app-7db23c94cc153c11.js:2223 [2024-09-22T05:24:31.710Z] @firebase/firestore: Firestore (10.13.2): FirebaseAuthCredentialsProvider Auth detected _app-7db23c94cc153c11.js:5857 [FIRESTORE] 2024-09-22T05:24:31.711Z undefined trackDocs ["userPublic",["TjcBmypHVuPIVy6zcPlgUhttJs72","userBot"]] _app-7db23c94cc153c11.js:5857 [FIRESTORE] 2024-09-22T05:24:31.712Z undefined trackDoc ["userPublic",[]] TjcBmypHVuPIVy6zcPlgUhttJs72 _app-7db23c94cc153c11.js:5857 [FIRESTORE] 2024-09-22T05:24:31.713Z undefined trackDoc ["userPrivate",[]] TjcBmypHVuPIVy6zcPlgUhttJs72 _app-7db23c94cc153c11.js:1987 [PREFERENCES] load {"debugLocation":null,"hasAppLeftByPromoCode":false,"installed":1726977989578,"lastOnboardingPage":null,"lastRateApp":null,"loaded":true,"onboardImage":false,"overrideFeatureFlags":null,"overrideSubscriptionState":null,"shownFreeInviteThanks":false,"playTextEnabled":true,"leftSidebarShow":true,"rightSidebarShow":false,"rightSidebarWidth":400,"microphone":null,"webcam":null,"speaker":null,"showFaceDetection":false,"pinnedConversationIds":[],"unreadAllConversations":0,"conversationId":null} _app-7db23c94cc153c11.js:2223 [2024-09-22T05:24:31.723Z] @firebase/firestore: Firestore (10.13.2): FirebaseAppCheckTokenProvider AppCheck not yet detected _api.js?onload=iframefcb304606:24 Uncaught TypeError: u[v] is not a function at Ka.N. [as loaded_0] (api.js?onload=__iframefcb304606:24:129) at cb=gapi.loaded0?le=scs:1:6 Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox. _app-7db23c94cc153c11.js:2013 [batch] MIXPANEL REQUEST: [{…}] _app-7db23c94cc153c11.js:2223 [2024-09-22T05:25:02.006Z] @firebase/firestore: Firestore (10.13.2): FirestoreClient Received user= TjcBmypHVuPIVy6zcPlgUhttJs72 _app-7db23c94cc153c11.js:2223 [2024-09-22T05:25:02.007Z] @firebase/firestore: Firestore (10.13.2): FirestoreClient Using default OnlineComponentProvider _app-7db23c94cc153c11.js:2223 [2024-09-22T05:25:02.008Z] @firebase/firestore: Firestore (10.13.2): FirestoreClient Using default OfflineComponentProvider _app-7db23c94cc153c11.js:2223 [2024-09-22T05:25:02.009Z] @firebase/firestore: Firestore (10.13.2): FirestoreClient Initializing OfflineComponentProvider _app-7db23c94cc153c11.js:2223 [2024-09-22T05:25:02.014Z] @firebase/firestore: Firestore (10.13.2): FirestoreClient Initializing OnlineComponentProvider _app-7db23c94cc153c11.js:2223 [2024-09-22T05:25:02.018Z] @firebase/firestore: Firestore (10.13.2): MemoryPersistence Starting transaction: Allocate target _app-7db23c94cc153c11.js:2223 [2024-09-22T05:25:02.021Z] @firebase/firestore: Firestore (10.13.2): MemoryPersistence Starting transaction: Execute query _app-7db23c94cc153c11.js:2223 [2024-09-22T05:25:02.023Z] @firebase/firestore: Firestore (10.13.2): QueryEngine Using full collection scan to execute query: Query(target=Target(userPrivate/TjcBmypHVuPIVy6zcPlgUhttJs72/userConversation, filters: [hidden == false], orderBy: [created (desc), name__ (desc)]); limitType=F) _app-7db23c94cc153c11.js:2223 [2024-09-22T05:25:02.027Z] @firebase/firestore: Firestore (10.13.2): WebChannelConnection Creating RPC 'Listen' stream 0x4e100787: https://firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel {"httpSessionIdParam":"gsessionid","initMessageHeaders":{"X-Goog-Api-Client":"gl-js/ f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_n48tFs3TKdJM0qwVXjSCos3ulgU2D0jTzbYJ1KtfW3Ka-ResTo73SgdmZr19zAUqwAPk2RfeJ4u-0N_EhIVfZyQE5uH_VlwKhrvB_rmE9srn63uXwEjozkDbdK8vXWU026H0nn8ELdZQt2jlkQ52K4CXc2Nx-2APwpG6vBB8yZD45lg"},"messageUrlParams":{"database":"projects/app-prod-55a67/databases/(default)"},"sendRawJson":true,"supportsCrossDomainXhr":true,"internalChannelParams":{"forwardChannelRequestTimeoutMs":600000},"forceLongPolling":false,"detectBufferingProxy":true,"xmlHttpFactory":{"l":null,"j":false},"encodeInitMessageHeaders":true}

Detailed Problem Description

onSnapshot is called and the first response takes approx 30 seconds. This only happens on mobile, on desktop it is nearly instant.

Steps and code to reproduce issue

This happens on web page load

google-oss-bot commented 2 months ago

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

justinmann commented 2 months ago

The issue was caused by next-firebase-auth https://github.com/gladly-team/next-firebase-auth

I removed this library and switched to client side only auth and onSnapshot performed correctly.