Juul / tail-stream

Like `tail -f` but a stream. Like fs.createReadStream but keeps reading as the file grows.
Other
33 stars 13 forks source link

File getting truncated with 'beginAt' set to 'end' not always detected #26

Open user58823 opened 3 years ago

user58823 commented 3 years ago

When the 'beginAt' option is set to 'end', before the file grows for the first time, no matter how much that file gets truncated, it will not be detected and all new data is completely skipped until the file grows beyond its original size again.

As far as I can tell, you need to add this.lastSize = stat.size; somewhere inside this if-block: https://github.com/Juul/tail-stream/blob/d460a2b46d76325780ab6199b706964a38dace93/index.js#L222

Juul commented 3 years ago

I would gladly accept a pull request but I don't have time to troubleshoot this myself right now :)

On Tue, Apr 20, 2021 at 12:10 PM user58823 @.***> wrote:

When the 'beginAt' option is set to 'end', before the file grows for the first time, no matter how much that file gets truncated, it will not be detected and all new data is completely skipped until the file grows beyond its original size again.

As far as I can tell, you need to add this.lastSize = stat.size; somewhere inside this if-block:

https://github.com/Juul/tail-stream/blob/d460a2b46d76325780ab6199b706964a38dace93/index.js#L222

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Juul/tail-stream/issues/26, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA57AHIKBYK4WFYZDX4FCDTJXGTHANCNFSM43I3GTCA .