trickle-observe 0.2.1 → 0.2.2
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/dist/transport.js +5 -1
- package/package.json +1 -1
- package/src/transport.ts +4 -1
package/dist/transport.js
CHANGED
|
@@ -202,8 +202,12 @@ function silentError() {
|
|
|
202
202
|
}
|
|
203
203
|
// Register process exit handler to flush remaining events
|
|
204
204
|
if (typeof process !== 'undefined' && process.on) {
|
|
205
|
+
let flushing = false;
|
|
205
206
|
process.on('beforeExit', () => {
|
|
206
|
-
|
|
207
|
+
if (flushing || queue.length === 0)
|
|
208
|
+
return;
|
|
209
|
+
flushing = true;
|
|
210
|
+
flush().catch(silentError).finally(() => { flushing = false; stopTimer(); });
|
|
207
211
|
});
|
|
208
212
|
// SIGTERM / SIGINT: attempt a sync-ish flush
|
|
209
213
|
const exitHandler = () => {
|
package/package.json
CHANGED
package/src/transport.ts
CHANGED
|
@@ -178,8 +178,11 @@ function silentError(): void {
|
|
|
178
178
|
|
|
179
179
|
// Register process exit handler to flush remaining events
|
|
180
180
|
if (typeof process !== 'undefined' && process.on) {
|
|
181
|
+
let flushing = false;
|
|
181
182
|
process.on('beforeExit', () => {
|
|
182
|
-
|
|
183
|
+
if (flushing || queue.length === 0) return;
|
|
184
|
+
flushing = true;
|
|
185
|
+
flush().catch(silentError).finally(() => { flushing = false; stopTimer(); });
|
|
183
186
|
});
|
|
184
187
|
|
|
185
188
|
// SIGTERM / SIGINT: attempt a sync-ish flush
|