NuxtN
Nuxt3y ago
Rifat

Why nitro doesn't wait for async plugins to complete operation?

I have a plugin that connects to mongodb. But connecting to mongodb takes some times. But nitro doesn't wait for that plugin to execute completely and then start the server. Instead it starts immediately (before connecting to mongodb) and starts responding. As a result error occurs.
Plugin code=>
export default defineNitroPlugin(async ev => {
    await mongo.init() // connects to mongodb
})
Was this page helpful?