@logdna/tail-file
Advanced tools
Comparing version 2.0.6 to 2.0.7
@@ -0,1 +1,9 @@ | ||
# 2021-06-02, Version 2.0.7 (Stable) | ||
* [[558e3233bf](https://github.com/logdna/tail-file-node/commit/558e3233bf)] - deps: tap@15.0.9 (Darin Spivey) | ||
* [[01b7dd722f](https://github.com/logdna/tail-file-node/commit/01b7dd722f)] - deps: eslint-config-logdna@5.1.0 (Darin Spivey) | ||
* [[36de02bc9e](https://github.com/logdna/tail-file-node/commit/36de02bc9e)] - deps: eslint@7.27.0 (Darin Spivey) | ||
* [[08c8472cbf](https://github.com/logdna/tail-file-node/commit/08c8472cbf)] - fix: Error on rotated file if new file takes time to appear (Darin Spivey) | ||
* [[14faefe57e](https://github.com/logdna/tail-file-node/commit/14faefe57e)] - refactor: memory-usage tests should use a temp directory (Darin Spivey) | ||
# 2021-02-09, Version 2.0.6 (Stable) | ||
@@ -2,0 +10,0 @@ |
@@ -20,3 +20,3 @@ 'use strict' | ||
const NOOP = () => {} | ||
function NOOP() {} | ||
@@ -124,5 +124,7 @@ class TailFile extends Readable { | ||
// Use the file handle since it remains open even if the file name has changed | ||
const stats = await this[kFileHandle].stat() | ||
const fileHandleTemp = this[kFileHandle] // Prevent races when closing | ||
this[kFileHandle] = null | ||
const stats = await fileHandleTemp.stat() | ||
const lengthToEnd = stats.size - this[kStartPos] | ||
const {buffer} = await this[kFileHandle].read( | ||
const {buffer} = await fileHandleTemp.read( | ||
Buffer.alloc(lengthToEnd) | ||
@@ -134,4 +136,3 @@ , 0 | ||
this.push(buffer) | ||
await this[kFileHandle].close() | ||
this[kFileHandle] = null | ||
await fileHandleTemp.close() | ||
return | ||
@@ -173,4 +174,16 @@ } | ||
} else if (this[kInode] !== stats.ino) { | ||
// File renamed/rolled | ||
await this._readRemainderFromFileHandle() | ||
// File renamed/rolled between polls without triggering `ENOENT`. | ||
// Conditional since this *may* have already been done if `ENOENT` threw earlier. | ||
if (this[kFileHandle]) { | ||
try { | ||
await this._readRemainderFromFileHandle() | ||
} catch (error) { | ||
const err = new Error('Could not read remaining bytes from old FH') | ||
err.meta = { | ||
error: error.message | ||
, code: error.code | ||
} | ||
this.emit('tail_error', err) | ||
} | ||
} | ||
await this._openFile() | ||
@@ -211,2 +224,3 @@ this[kStartPos] = 0 | ||
if (this[kFileHandle]) { | ||
// The .stat() via polling may have happened during a file rename/roll. | ||
// Don't lose the last lines in the file if it previously existed. | ||
@@ -213,0 +227,0 @@ // Perhaps it has not been re-created yet (or won't be) |
{ | ||
"name": "@logdna/tail-file", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"description": "A node.js version of unix's `tail -f` command", | ||
@@ -74,6 +74,6 @@ "main": "index.js", | ||
"@commitlint/config-conventional": "^11.0.0", | ||
"eslint": "^7.10.0", | ||
"eslint-config-logdna": "^2.0.0", | ||
"eslint": "^7.27.0", | ||
"eslint-config-logdna": "^5.1.0", | ||
"husky": "^4.3.0", | ||
"tap": "^14.10.7", | ||
"tap": "^15.0.9", | ||
"tap-xunit": "^2.4.1" | ||
@@ -83,3 +83,2 @@ }, | ||
"100": true, | ||
"esm": false, | ||
"ts": false, | ||
@@ -89,2 +88,3 @@ "jsx": false, | ||
"jobs": 1, | ||
"timeout": 60, | ||
"coverage-report": [ | ||
@@ -91,0 +91,0 @@ "text", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43184
436