Skip to content

Commit f7de741

Browse files
committed
Unref timers so they don't block the event loop.
1 parent 7a2d07f commit f7de741

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Converted to ESM module.
66
- Requires Node >= 16.
77
- Uses timers-obj@3.
8+
- Unref timers so they don't block the event loop.
89

910
## v2.2.4 2019-10-07
1011

src/file-timestamp-stream.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,15 @@ export class FileTimestampStream extends Writable {
163163
newStream.on("error", newStreamErrorHandler)
164164
this.streamErrorHandlers.set(newFilename, newStreamErrorHandler)
165165

166-
const newCloser = timers.interval(FileTimestampStream.CLOSE_UNUSED_FILE_AFTER, () => {
167-
if (newFilename !== this.newFilename()) {
168-
newCloser.close()
169-
this.closers.delete(newFilename)
170-
newStream.end()
171-
}
172-
})
166+
const newCloser = timers
167+
.interval(FileTimestampStream.CLOSE_UNUSED_FILE_AFTER, () => {
168+
if (newFilename !== this.newFilename()) {
169+
newCloser.close()
170+
this.closers.delete(newFilename)
171+
newStream.end()
172+
}
173+
})
174+
.unref()
173175
this.closer = closer
174176
this.closers.set(newFilename, newCloser)
175177

0 commit comments

Comments
 (0)