Skip to content

Commit

Permalink
Adds top-level uncaught exception handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrés Elizondo committed Nov 6, 2024
1 parent 02fb8ff commit d32650a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ import { Kafka, Producer } from 'kafkajs';
import { resolve } from 'path';
import { Connection, ConnectionOptions, createConnection } from 'typeorm';

process.on('unhandledRejection', (reason, promise) => {
logger.fatal('Unhandled Rejection:', reason);
process.exit(1);
});

config({ path: resolve(__dirname, '../../.env') });

let producer: Producer | null = null;
Expand Down Expand Up @@ -128,7 +133,7 @@ createConnection(ormConfig as ConnectionOptions)
})
.catch((error) => {
logger.fatal(error);
process.exit();
process.exit(1);
});

async function schedule(connection: Connection | null, producer: Producer | null, func: any, funcName: string) {
Expand Down

0 comments on commit d32650a

Please sign in to comment.