Skip to content

Commit b03a0aa

Browse files
authored
Merge pull request #14 from kryptokrauts/feat/more-exception-logging
feat: increase logging in case of unknown errors, bump to 1.0.17
2 parents 8e31453 + ae02350 commit b03a0aa

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kryptokrauts/event-processor-node-lib",
3-
"version": "1.0.16",
3+
"version": "1.0.17",
44
"description": "Wrapper for ease listening on antelope blockchain based on @blockmatic/antelope-ship-reader",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/eosio/ship-reader-wrapper.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { fetchAbi, getHeadBlockNum } from './chain-api';
2525

2626
const logger = getLogger('ship-reader-wrapper');
2727
const signal_traps = ['SIGTERM', 'SIGINT', 'SIGUSR2'];
28-
const error_types = ['unhandledRejection', 'uncaughtException'];
2928

3029
export class ShipReaderWrapper {
3130
config: ShipReaderWrapperConfig = undefined;
@@ -46,9 +45,10 @@ export class ShipReaderWrapper {
4645
});
4746

4847
// handle unexpected error
49-
error_types.forEach(type => {
50-
this.handleEvent(type);
51-
});
48+
process.on('unhandledRejection', reason =>
49+
this.sendEventAndEndProcess('unhandledRejection', reason),
50+
);
51+
process.on('uncaughtException', err => this.sendEventAndEndProcess('uncaughtException', err));
5252
}
5353

5454
/**
@@ -389,7 +389,12 @@ export class ShipReaderWrapper {
389389
resetEvent && (await this.kafka_wrapper.sendEvent(resetEvent, 'reset_event'));
390390
await this.gracefulShutdown();
391391
} finally {
392-
process.kill(process.pid, type);
392+
const isSignal = ['SIGTERM', 'SIGINT', 'SIGUSR2'].includes(type);
393+
if (isSignal) {
394+
process.kill(process.pid, type as NodeJS.Signals);
395+
} else {
396+
process.exit(1);
397+
}
393398
}
394399
}
395400

0 commit comments

Comments
 (0)