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}`);
|
console.log(`MongoDB Connected: ${conn.connection.host}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error: ${error.message}`);
|
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 connectDB = require('./config/db');
|
||||||
const path = require('path');
|
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
|
// Load env vars
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user