How to properly setup mongoose without external modules

I am using nuxt server plugins to create a connection to the database using mongoose and closing the connections with nuxt hooks 'close' event. Now everything is working fine as expected in dev. But as soon as i run pnmp run build, the process gets stuck and i need to manually exit the process using ctrl + c after which I run the node output command to run the localhost in production mode That was all fine until I had to deploy the same thing on nuxt amplify, which after getting stuck on nuxt build, times out. Can someone help me here? I have the same config and everything as is, working in NUXT3, only upgraded as I had to also upgrade node version because amplify is stopping support for node 18 after mid September
2 Replies
kapa.ai
kapa.ai2d ago
Hi @Lovish Aggarwal. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I'm sorry, but the knowledge sources provided do not contain explicit information about setting up a custom Mongoose connection in Nuxt (without external modules) and handling build process hangs, especially in the context of Nuxt 4 or recent Node versions on AWS Amplify. However, based on the related issues in the sources, here are some relevant points: - There are known issues where the Nuxt build process can hang, especially when custom server plugins or connections (like Mongoose) are not properly closed or are interfering with the build lifecycle. The use of Nuxt hooks such as close is correct for cleaning up resources, but there is no detailed example or troubleshooting guide in the sources for your specific scenario. - For deployment on AWS Amplify, there are cases where switching between SSR and SSG can cause deployment issues, but these are not directly related to Mongoose or custom server plugins. One user resolved a deployment issue by updating the Amplify app platform type, but this was for static vs. SSR output, not for build hangs due to database connections AWS Amplify - NUXT 3 deploy. - The sources do not provide a step-by-step guide or best practices for integrating Mongoose manually in Nuxt 3/4, nor do they address build process hangs caused by such integrations. Given this, I recommend: - Double-checking that your Mongoose connection logic is not being executed during the build phase. Ensure that any database connections are only established at runtime, not during build. - Reviewing your server plugin to ensure it does not inadvertently trigger connections or long-running processes during build. - If possible, try to isolate the Mongoose logic to only run in server runtime (not during build or generate). Unfortunately, without more specific information in the knowledge sources, I cannot provide a definitive solution to your problem. If you have access to more detailed logs or can share your server plugin code, that might help in further troubleshooting. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2d ago
<@1264628096506532017> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?