N
Nuxt2y 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
})
export default defineNitroPlugin(async ev => {
await mongo.init() // connects to mongodb
})
3 Replies
Rifat
RifatOP2y ago
Doesn't wait for any async function to execute completely
Cue
Cue2y ago
Plug-ins run synchronously as per docs. Track here: https://github.com/unjs/nitro/issues/915
GitHub
Make plugins async · Issue #915 · unjs/nitro
For the benefit of bootstrapping plugins it is usefull to make plugins load async. nitro/src/runtime/app.ts Lines 89 to 91 in ed3a480 for (const plugin of plugins) { plugin(app); } Can someone expl...
Rifat
RifatOP2y ago
They haven't solved this yet
Want results from more Discord servers?
Add your server