Skip to content

Commit

Permalink
fix!: Set max listeners to tolerate backpressure
Browse files Browse the repository at this point in the history
If a file isn't immediately put into flowing mode, then backpressure
could be invoked right away. Doing so can add many more event listeners
onto the stream as it uses the async iterator. This increases the max
listeners above the default for a little more tolerance before seeing
the nasty node warnings about event emitter leaks.

BREAKING CHANGE: `node 16` is becoming unsupported soon. Change the
supported versions to be >= `18`

Fixes: #41
  • Loading branch information
darinspivey committed Feb 13, 2024
1 parent c914dd2 commit 9946590
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.0.0
20.11.0
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pipeline {
axes {
axis {
name 'NODE_VERSION'
values '12', '14', '16', '18'
values '18', '20'
}
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ If backward-compatibility is lost over time, a `major` version will be released
the latest version, and deprecating incompatible versions. Users are then encouraged to try
previous versions of this package for those deprecated versions of Node.js.

**Node.js versions**: `12`, `14`, `16`, `18`
**Node.js versions**: `18`, `20`

## Usage

Expand Down
1 change: 1 addition & 0 deletions lib/tail-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ class TailFile extends Readable {
...this[kOpts].readStreamOpts
, start: this[kStartPos]
})
stream.setMaxListeners(100) // Allow for additional listeners when reading backpressured chunks
await this._readChunks(stream)
} catch (err) {
// Possible file removal. Let auto-retry handle it.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
"engineStrict": true,
"engines": {
"node": ">= 12"
"node": ">= 18"
},
"bugs": {
"url": "https://github.com/logdna/tail-file-node/issues"
Expand Down

0 comments on commit 9946590

Please sign in to comment.