Skip to content

Commit df5b008

Browse files
committed
Unref the still-running-dont-update-again timer
1 parent 3af37bf commit df5b008

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export async function runHTK(options: {
241241
// If we don't, we'll redownload the same update again every check.
242242
// We don't want to block it completely though, in case this server
243243
// stays open for a very long time.
244-
return delay(1000 * 60 * 60 * 6);
244+
return delay(1000 * 60 * 60 * 6, { unref: true });
245245
}
246246

247247
// Report any HTTP response errors cleanly & explicitly:

src/util/promise.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
export function delay(durationMs: number): Promise<void> {
2-
return new Promise((resolve) => setTimeout(resolve, durationMs));
1+
export function delay(durationMs: number, options: { unref?: boolean } = {}): Promise<void> {
2+
return new Promise((resolve) => {
3+
const timer = setTimeout(resolve, durationMs);
4+
if (options.unref) timer.unref();
5+
});
36
}
47

58
export async function waitUntil<T extends unknown>(

0 commit comments

Comments
 (0)