Closed GalacticHypernova closed 5 months ago
For anyone else who may experience this, here is the solution that seems to have worked for me (and no, I am not even kidding, this is the only way I managed to resolve this):
console.log("HELLO THERE")
console.log(import.meta.prerender, import.meta.dev, import.meta.test, import.meta.env?.PROD)
if(!import.meta.prerender){
// Handle mongoose connection here
}
Without the console.logs it had still presented the same issue, which is why they are needed for this fix to work (again, at least in my case)
@farnabaz this likely isn't intended behavior, right?
Environment
Build Modules: -
Reproduction
https://stackblitz.com/edit/github-ftqn23?file=pages%2F[...slug].vue,nuxt.config.ts,server%2Fplugins%2Fstartup.ts
Other prerequisites:
For more information, please refer to https://discord.com/channels/473401852243869706/1002541842409193563/1168471513842864128 (in the Nuxt discord)
Describe the bug
When using @nuxt/content, during the server build process the prerenderer gets initialized to prerender routes. This causes the server plugins to execute, which run ~/server/plugins/startup.ts. When the connection is valid and runs as expected, it is connected before the build is done, and when the build process finally reaches the ending message of "you can preview this build...." it never actually finishes, and the build must be stopped using ctrl + c, otherwise it hangs indefinitely.
Additional context
The plugin appears to run correctly but during the hang there are no error messages, which make it extremely hard to debug. If this cannot be reproduced, I would happily share my screen showcasing the behavior.
Logs