lightning 5.16.5 → 5.16.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,7 @@ const connectionFailureMessage = 'failed to connect to all addresses';
|
|
|
10
10
|
const events = ['end', 'error', 'invoice_updated', 'status'];
|
|
11
11
|
const msPerSec = 1e3;
|
|
12
12
|
const restartSubscriptionMs = 1000 * 30;
|
|
13
|
+
const sumOf = arr => arr.reduce((sum, n) => sum + n, Number());
|
|
13
14
|
const updateEvent = 'invoice_updated';
|
|
14
15
|
|
|
15
16
|
/** Subscribe to invoices
|
|
@@ -112,14 +113,30 @@ module.exports = args => {
|
|
|
112
113
|
|
|
113
114
|
isFinished = true;
|
|
114
115
|
|
|
116
|
+
const listenerCount = eventEmitter.listenerCount(updateEvent);
|
|
117
|
+
|
|
118
|
+
// Exit early when there are no listeners
|
|
119
|
+
if (!listenerCount) {
|
|
120
|
+
return cbk(null, {listener_count: listenerCount});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Delay restart when there are listeners
|
|
115
124
|
return setTimeout(() => {
|
|
116
|
-
return cbk(null, {
|
|
117
|
-
listener_count: eventEmitter.listenerCount(updateEvent),
|
|
118
|
-
});
|
|
125
|
+
return cbk(null, {listener_count: listenerCount});
|
|
119
126
|
},
|
|
120
127
|
args.restart_delay_ms || restartSubscriptionMs);
|
|
121
128
|
};
|
|
122
129
|
|
|
130
|
+
// Finish early when all listeners are removed
|
|
131
|
+
eventEmitter.on('removeListener', () => {
|
|
132
|
+
// Exit early when there are still active listeners
|
|
133
|
+
if (!!sumOf(events.map(n => eventEmitter.listenerCount(n)))) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return finished();
|
|
138
|
+
});
|
|
139
|
+
|
|
123
140
|
// Relay invoice updates to the emitter
|
|
124
141
|
subscription.on('data', invoice => {
|
|
125
142
|
try {
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"@grpc/grpc-js": "1.6.8",
|
|
11
11
|
"@grpc/proto-loader": "0.7.0",
|
|
12
12
|
"@types/express": "4.17.13",
|
|
13
|
-
"@types/node": "18.6.
|
|
13
|
+
"@types/node": "18.6.3",
|
|
14
14
|
"@types/request": "2.48.8",
|
|
15
15
|
"@types/ws": "8.5.3",
|
|
16
16
|
"async": "3.2.4",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"directory": "test/typescript"
|
|
60
60
|
},
|
|
61
61
|
"types": "index.d.ts",
|
|
62
|
-
"version": "5.16.
|
|
62
|
+
"version": "5.16.6"
|
|
63
63
|
}
|