nuxt-community / firebase-module

🔥 Easily integrate Firebase into your Nuxt project. 🔥
https://firebase.nuxtjs.org
MIT License
641 stars 99 forks source link

@nuxtjs/sitemap - The command 'nuxt generate' finished but did not exit after 5s #584

Closed simeon9696 closed 2 years ago

simeon9696 commented 2 years ago

I just added in the sitemap module and the warning at the end of this post came up. I'm not sure where to start with this one because the only change was adding in the sitemap module.

Here's my routes.generate:

generate: {
    async routes() {
      try {
        const { default: firebase } = await import('firebase/app')

        await import('firebase/firestore')
        const config = {
          apiKey: process.env.apiKey,
          authDomain: process.env.authDomain,
          databaseURL: process.env.databaseURL,
          projectId: process.env.projectId,
          storageBucket: process.env.storageBucket,
          messagingSenderId: process.env.messagingSenderId,
          appId: process.env.appId,
          measurementId: process.env.measurementId,
        }
        if (!firebase.apps.length) {
          firebase.initializeApp(config)
        }

        const app = firebase.apps[0]

        const qProducts = await app
          .firestore()
          .collection('products')
          .where('visible', '==', true)
          .get()

        if(qProducts.empty) return [];

        const products = qProducts.docs.map((doc) => {
          return {
            paylod: { ...doc.data(), id: doc.id },
            route: `/${doc.data().linkCategory}/${doc.data().linkName}`,
          }
        })

        return products
      } catch (error) {
        console.error(error)
      }
    },

My firebase config:

  firebase: {
    terminateDatabasesAfterGenerate: true,
    config: {
      apiKey: process.env.apiKey,
      authDomain: process.env.authDomain,
      databaseURL: process.env.databaseURL,
      projectId: process.env.projectId,
      storageBucket: process.env.storageBucket,
      messagingSenderId: process.env.messagingSenderId,
      appId: process.env.appId,
      measurementId: process.env.measurementId,
    },
    services: {
      analytics: true,
      performance: true,
      auth: {
        ssr: false,
        initialize: {
          onAuthStateChangedAction: 'auth/onAuthStateChangedAction',
        },
      },
      storage: {
        emulatorPort: process.env.NODE_ENV === 'development' ? 9199 : undefined,
        emulatorHost: 'localhost',
      },
      functions: {
        location: 'us-central1',
        emulatorPort: process.env.NODE_ENV === 'development' ? 5001 : undefined,
        emulatorHost: 'http://localhost',
      },

      firestore: {
        emulatorPort: process.env.NODE_ENV === 'development' ? 8080 : undefined,
        emulatorHost: 'localhost',
        enablePersistence: {
          synchronizeTabs: true,
        },
      },
    },
  },

My sitemap config:

    sitemap: {
    gzip:true,
    hostname: '<myhostnamehere>',
    exclude: [
      '/admin/**'
    ],
  },

Version

@nuxtjs/firebase: 7.6.1, firebase: 8.10.0 nuxt: 2.15.8

What is Expected?

The database terminates after generation

What is actually happening?

Getting this error: The command 'nuxt generate' finished but did not exit after 5s

╭──────────────────────────────────────────────────────────────────────────────────────╮
   │                                                                                      │
   │   ⚠ Nuxt Warning                                                                     │
   │                                                                                      │
   │   The command 'nuxt generate' finished but did not exit after 5s                     │
   │   This is most likely not caused by a bug in Nuxt                                    │
   │   Make sure to cleanup all timers and listeners you or your plugins/modules start.   │
   │   Nuxt will now force exit                                                           │
   │                                                                                      │
   │   DeprecationWarning: Starting with Nuxt version 3 this will be a fatal error        │
   │                                                                                      │
   ╰──────────────────────────────────────────────────────────────────────────────────────╯
lupas commented 2 years ago

Hey @simeon9696

This warning happens because either Firestore or the RealtimeDb are not terminated at the end of Nuxt Generate.

Try following the steps described here: https://firebase.nuxtjs.org/community/faq#nuxt-generate-warns-with-nuxt-generate-finished-but-did-not-exit