Fix MongoDB connection issue in production builds

Prevent database disconnection in dbDisconnect() to avoid "Client must be connected" errors in production. The connection pool handles cleanup automatically.
This commit is contained in:
2025-09-12 15:02:24 +02:00
parent 21a2f0068d
commit f269515574
+3 -5
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;
};