Skip to content

Commit

Permalink
Merge branch 'master' into test-on-LTS-nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbar42 authored Aug 17, 2021
2 parents 4b7974a + e197e50 commit 700dc91
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 92 deletions.
14 changes: 8 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var Graceful = /** @class */ (function () {
process.removeListener('uncaughtException', Graceful.exceptionListener);
}
},
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(Graceful, "captureRejections", {
Expand All @@ -40,7 +40,7 @@ var Graceful = /** @class */ (function () {
process.removeListener('unhandledRejection', Graceful.rejectionListener);
}
},
enumerable: true,
enumerable: false,
configurable: true
});
Graceful.on = function (signal, listener) {
Expand Down Expand Up @@ -116,8 +116,9 @@ var Graceful = /** @class */ (function () {
Graceful.updateRegistration = function () {
if (Graceful.listeners.length && !Graceful.isRegistered) {
var _loop_1 = function (deadlySignal) {
Graceful.signalsListeners[deadlySignal] = function () { return Graceful.onDeadlyEvent(deadlySignal); };
process.on(deadlySignal, Graceful.signalsListeners[deadlySignal]);
var listener = function () { return Graceful.onDeadlyEvent(deadlySignal); };
Graceful.signalsListeners[deadlySignal] = listener;
process.on(deadlySignal, listener);
};
for (var _i = 0, _a = Graceful.DEADLY_SIGNALS; _i < _a.length; _i++) {
var deadlySignal = _a[_i];
Expand All @@ -128,8 +129,9 @@ var Graceful = /** @class */ (function () {
else if (!Graceful.listeners.length && Graceful.isRegistered) {
for (var _b = 0, _c = Graceful.DEADLY_SIGNALS; _b < _c.length; _b++) {
var deadlySignal = _c[_b];
if (Graceful.signalsListeners[deadlySignal]) {
process.removeListener(deadlySignal, Graceful.signalsListeners[deadlySignal]);
var listener = Graceful.signalsListeners[deadlySignal];
if (listener) {
process.removeListener(deadlySignal, listener);
delete Graceful.signalsListeners[deadlySignal];
}
}
Expand Down
10 changes: 6 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,16 @@ export default class Graceful {
private static updateRegistration() {
if (Graceful.listeners.length && !Graceful.isRegistered) {
for (const deadlySignal of Graceful.DEADLY_SIGNALS) {
Graceful.signalsListeners[deadlySignal] = () => Graceful.onDeadlyEvent(deadlySignal);
process.on(deadlySignal as any, Graceful.signalsListeners[deadlySignal]);
const listener = () => Graceful.onDeadlyEvent(deadlySignal);
Graceful.signalsListeners[deadlySignal] = listener
process.on(deadlySignal as any, listener);
}
Graceful.isRegistered = true
} else if (!Graceful.listeners.length && Graceful.isRegistered) {
for (const deadlySignal of Graceful.DEADLY_SIGNALS) {
if (Graceful.signalsListeners[deadlySignal]) {
process.removeListener(deadlySignal as any, Graceful.signalsListeners[deadlySignal]);
const listener = Graceful.signalsListeners[deadlySignal]
if (listener) {
process.removeListener(deadlySignal, listener);
delete Graceful.signalsListeners[deadlySignal];
}
}
Expand Down
Loading

0 comments on commit 700dc91

Please sign in to comment.