fix: prevent backend from crashing on unhandled errors to diagnose restart loop

This commit is contained in:
2026-09-23 01:10:32 +05:30
parent d673919fec
commit 862c045176
2 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -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);
} }
}; };
+7
View File
@@ -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();