Skip to content

Commit

Permalink
Merge pull request #162 from 0xProject/andres/prod-event-scraper-catc…
Browse files Browse the repository at this point in the history
…h-exceptions

Adds top-level uncaught exception handler.
  • Loading branch information
AndresElizondo authored Nov 6, 2024
2 parents 02fb8ff + d32650a commit 315abc7
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 315abc7

Please sign in to comment.