firebase / firebase-js-sdk

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

Firebase init takes 20s more by "FirebaseAppCheckTokenProvider AppCheck not yet detected" #8381

Closed xianbinKit closed 3 months ago

xianbinKit commented 4 months ago

Operating System

macOS Sonoma 14.2

Browser Version

Chrome Version 125.0.6422.142 (Official Build) (arm64)

Firebase SDK Version

10.12.4

Firebase SDK Product:

Firestore

Describe your project's tooling

Nuxtjs 3 + firebase javascript sdk

Describe the problem

firebase init takes 20 more seconds before first getDoc, please see firebase debug log below.

App Check is not active on firebase web console. I don't know where the "FirebaseAppCheckTokenProvider AppCheck" from

I have tried firebase v10.12.3, same issue.

I have tried another web using same firebase project and same version ( 10.12.3), another version is very fast.

the only different is : there is a warning "Third-party cookie will be blocked. Learn more in the Issues tab." in the one which has issue.

Tried Safari : no problem, no Third-party cookie warning Tried in Chrome incognito tab: no problem, no Third-party cookie warning

Steps and code to reproduce issue

import { initializeApp } from 'firebase/app'
import { getAuth } from "firebase/auth"
import { getFirestore, setLogLevel } from 'firebase/firestore'
import { getAnalytics } from "firebase/analytics"

export default defineNuxtPlugin(nuxtApp => {
    const config = useRuntimeConfig()

    const firebaseConfig = {
        apiKey: import.meta.env.VITE_FIREBASE_apiKey,
        authDomain: import.meta.env.VITE_FIREBASE_authDomain,
        projectId: import.meta.env.VITE_FIREBASE_projectId,
        storageBucket: import.meta.env.VITE_FIREBASE_storageBucket,
        messagingSenderId: import.meta.env.VITE_FIREBASE_messagingSenderId,
        appId: import.meta.env.VITE_FIREBASE_appId,
        measurementId: import.meta.env.VITE_FIREBASE_measurementId
    };

    const app = initializeApp(firebaseConfig)
    console.log('firebase init')
    // const analytics = getAnalytics(app)
    const auth = getAuth(app)

    const firestore = getFirestore(app)
    setLogLevel('debug')

    nuxtApp.vueApp.provide('auth', auth)
    nuxtApp.provide('auth', auth)

    nuxtApp.vueApp.provide('firestore', firestore)
    nuxtApp.provide('firestore', firestore)
})

// call getDoc somewhere on index.vue...

[2024-07-19T21:53:32.630Z] @firebase/firestore: Firestore (10.12.4): FirebaseAppCheckTokenProvider AppCheck not yet detected chunk-JCLT2C3F.js?v=e727d07d:1375

===== >here took 21 seconds

Third-party cookie will be blocked. Learn more in the Issues tab. ( only shows this warning on this project )

[2024-07-19T21:53:54.128Z] @firebase/firestore: Firestore (10.12.4): AsyncQueue Visibility state changed to hidden localhost/:1 Third-party cookie will be blocked. Learn more in the Issues tab. chunk-JCLT2C3F.js?v=e727d07d:1375

========> here took 5 seconds

[2024-07-19T21:53:59.058Z] @firebase/firestore: Firestore (10.12.4): FirestoreClient Received user= IFMJD5alI8RPwWCTVxD1XXqVvtw2 chunk-JCLT2C3F.js?v=e727d07d:1375

[2024-07-19T21:53:59.059Z] @firebase/firestore: Firestore (10.12.4): FirestoreClient Using default OnlineComponentProvider chunk-JCLT2C3F.js?v=e727d07d:1375

[2024-07-19T21:53:59.059Z] @firebase/firestore: Firestore (10.12.4): FirestoreClient Using default OfflineComponentProvider chunk-JCLT2C3F.js?v=e727d07d:1375

[2024-07-19T21:53:59.059Z] @firebase/firestore: Firestore (10.12.4): FirestoreClient Initializing OfflineComponentProvider chunk-JCLT2C3F.js?v=e727d07d:1375

[2024-07-19T21:53:59.059Z] @firebase/firestore: Firestore (10.12.4): FirestoreClient Initializing OnlineComponentProvider chunk-JCLT2C3F.js?v=e727d07d:1375

[2024-07-19T21:53:59.060Z] @firebase/firestore: Firestore (10.12.4): MemoryPersistence Starting transaction: Allocate target chunk-JCLT2C3F.js?v=e727d07d:1375

[2024-07-19T21:53:59.061Z] @firebase/firestore: Firestore (10.12.4): MemoryPersistence Starting transaction: Execute query chunk-JCLT2C3F.js?v=e727d07d:1375

[2024-07-19T21:53:59.061Z] @firebase/firestore: Firestore (10.12.4): QueryEngine Using full collection scan to execute query: Query(target=Target(globalSettings/productsSettings, orderBy: [name (asc)]); limitType=F)

dconeybe commented 3 months ago

Hello @xianbinKit. Apologies for the late reply. This issue slipped through the cracks.

I'm not proficient with Nuxtjs; could you provide a minimal sample application that reproduces the issue for you? Then I can give it a try and see if I can figure out what's going on. A link to a GitHub repository that I can clone would be ideal. Feel free to make it a private repo if you don't want to share your code broadly.

google-oss-bot commented 3 months ago

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

xianbinKit commented 3 months ago

Can't reproduce. the problem just gone ....

I think it's a Chrome issue.