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 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
- flush().catch(silentError);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trickle-observe",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Runtime type observability for JavaScript applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
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
- flush().catch(silentError);
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