Skip to content

Commit 31b0cde

Browse files
committed
fix(core): unref timer to not block node exit
1 parent a9ef859 commit 31b0cde

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/core/src/metrics/aggregator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class MetricsAggregator implements MetricsAggregatorBase {
3737
public constructor(private readonly _client: Client) {
3838
this._buckets = new Map();
3939
this._bucketsTotalWeight = 0;
40-
this._interval = setInterval(() => this._flush(), DEFAULT_FLUSH_INTERVAL);
40+
this._interval = setInterval(() => this._flush(), DEFAULT_FLUSH_INTERVAL).unref();
4141
this._flushShift = Math.floor((Math.random() * DEFAULT_FLUSH_INTERVAL) / 1000);
4242
this._forceFlush = false;
4343
}

packages/core/src/sessionflusher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export class SessionFlusher implements SessionFlusherLike {
3030
this._pendingAggregates = {};
3131
this._isEnabled = true;
3232

33-
// Call to setInterval, so that flush is called every 60 seconds
34-
this._intervalId = setInterval(() => this.flush(), this.flushTimeout * 1000);
33+
// Call to setInterval, so that flush is called every 60 seconds.
34+
this._intervalId = setInterval(() => this.flush(), this.flushTimeout * 1000).unref();
3535
this._sessionAttrs = attrs;
3636
}
3737

0 commit comments

Comments
 (0)