Fix MongoDB connection issue in production builds
Some checks failed
CI / update (push) Failing after 4s

Prevent database disconnection in dbDisconnect() to avoid "Client must be connected" errors in production. The connection pool handles cleanup automatically.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-12 15:02:24 +02:00
parent 6d46369eec
commit cdc744282c

View File

@@ -29,9 +29,7 @@ export const dbConnect = async () => {
};
export const dbDisconnect = async () => {
if (process.env.NODE_ENV === 'development') return;
if (mongoConnection.isConnected === 0) return;
await mongoose.disconnect();
mongoConnection.isConnected = 0;
// Don't disconnect in production to avoid "Client must be connected" errors
// The connection pool will handle connection cleanup automatically
return;
};