Skip to content

Commit ed21116

Browse files
authored
fix(node-sdk): ensure timers don't keep process alive (#303)
Unable to write a test for this, but tested manually.
1 parent f384857 commit ed21116

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

packages/node-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bucketco/node-sdk",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"license": "MIT",
55
"repository": {
66
"type": "git",

packages/node-sdk/src/batch-buffer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export default class BatchBuffer<T> {
5454
if (this.buffer.length >= this.maxSize) {
5555
await this.flush();
5656
} else if (!this.timer) {
57-
this.timer = setTimeout(() => this.flush(), this.intervalMs);
57+
this.timer = setTimeout(() => this.flush(), this.intervalMs).unref();
5858
}
5959
}
6060

packages/node-sdk/src/cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default function cache<T>(
4343
logger?.error("failed to update cached value", e);
4444
} finally {
4545
refreshPromise = undefined;
46-
timeoutId = setTimeout(update, ttl);
46+
timeoutId = setTimeout(update, ttl).unref();
4747
}
4848
};
4949

packages/node-sdk/src/rate-limiter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function newRateLimiter(windowSizeMs: number) {
4343

4444
function isAllowed(key: string): boolean {
4545
clearIntervalId =
46-
clearIntervalId || setInterval(() => clear(false), windowSizeMs);
46+
clearIntervalId || setInterval(() => clear(false), windowSizeMs).unref();
4747

4848
const now = Date.now();
4949

0 commit comments

Comments
 (0)