Fix MongoDB connection issue in production builds
Some checks failed
CI / update (push) Failing after 4s
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:
@@ -29,9 +29,7 @@ export const dbConnect = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const dbDisconnect = async () => {
|
export const dbDisconnect = async () => {
|
||||||
if (process.env.NODE_ENV === 'development') return;
|
// Don't disconnect in production to avoid "Client must be connected" errors
|
||||||
if (mongoConnection.isConnected === 0) return;
|
// The connection pool will handle connection cleanup automatically
|
||||||
|
return;
|
||||||
await mongoose.disconnect();
|
|
||||||
mongoConnection.isConnected = 0;
|
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user