fix: prevent backend from crashing on unhandled errors to diagnose restart loop
This commit is contained in:
@@ -6,7 +6,7 @@ const connectDB = async () => {
|
||||
console.log(`MongoDB Connected: ${conn.connection.host}`);
|
||||
} catch (error) {
|
||||
console.error(`Error: ${error.message}`);
|
||||
process.exit(1);
|
||||
// process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -4,6 +4,13 @@ const dotenv = require('dotenv');
|
||||
const connectDB = require('./config/db');
|
||||
const path = require('path');
|
||||
|
||||
process.on('uncaughtException', err => {
|
||||
console.error('Uncaught Exception:', err);
|
||||
});
|
||||
process.on('unhandledRejection', err => {
|
||||
console.error('Unhandled Rejection:', err);
|
||||
});
|
||||
|
||||
// Load env vars
|
||||
dotenv.config();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user