Skip to content

Commit 47343ef

Browse files
committed
feat: increase logging in case of unknown errors, bump to 1.0.17
1 parent 8e31453 commit 47343ef

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ export class ShipReaderWrapper {
4646
});
4747

4848
// handle unexpected error
49-
error_types.forEach(type => {
50-
this.handleEvent(type);
51-
});
49+
process.on('unhandledRejection', reason =>
50+
this.sendEventAndEndProcess('unhandledRejection', reason),
51+
);
52+
process.on('uncaughtException', err => this.sendEventAndEndProcess('uncaughtException', err));
5253
}
5354

5455
/**
@@ -389,7 +390,12 @@ export class ShipReaderWrapper {
389390
resetEvent && (await this.kafka_wrapper.sendEvent(resetEvent, 'reset_event'));
390391
await this.gracefulShutdown();
391392
} finally {
392-
process.kill(process.pid, type);
393+
const isSignal = signal_traps.includes(type);
394+
if (isSignal) {
395+
process.kill(process.pid, type as NodeJS.Signals);
396+
} else {
397+
process.exit(1);
398+
}
393399
}
394400
}
395401

0 commit comments

Comments
 (0)