Skip to content

Commit 315abc7

Browse files
Merge pull request #162 from 0xProject/andres/prod-event-scraper-catch-exceptions
Adds top-level uncaught exception handler.
2 parents 02fb8ff + d32650a commit 315abc7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ import { Kafka, Producer } from 'kafkajs';
3434
import { resolve } from 'path';
3535
import { Connection, ConnectionOptions, createConnection } from 'typeorm';
3636

37+
process.on('unhandledRejection', (reason, promise) => {
38+
logger.fatal('Unhandled Rejection:', reason);
39+
process.exit(1);
40+
});
41+
3742
config({ path: resolve(__dirname, '../../.env') });
3843

3944
let producer: Producer | null = null;
@@ -128,7 +133,7 @@ createConnection(ormConfig as ConnectionOptions)
128133
})
129134
.catch((error) => {
130135
logger.fatal(error);
131-
process.exit();
136+
process.exit(1);
132137
});
133138

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

0 commit comments

Comments
 (0)