tail-stream icon indicating copy to clipboard operation
tail-stream copied to clipboard

waitForCreate=true together with beginAt='end' results in file read from beginning on every change

Open kicsikrumpli opened this issue 6 years ago • 2 comments

as the title says

kicsikrumpli avatar Jul 05 '18 08:07 kicsikrumpli

Is this still an issue? If so, could you please provide steps to reproduce? Thanks

plastbox avatar Aug 23 '18 16:08 plastbox

It is indeed still an issue.

const ts = require('tail-stream');

var tstream = ts.createReadStream('nope.txt', {
    beginAt: 'end',
    waitForCreate: true,
    onMove: 'stay',
    detectTruncate: false,
    endOnError: false
});

tstream.on('data', function(data) {
    console.log("got data: " + data);
});

tstream.on('eof', function() {
    console.log("reached end of file");
});

Steps:

  1. if exists, remove nope.txt
  2. node index.js
  3. create nope.txt
  4. add one line and save
  5. add another line and save

output on console:

got data: 1
reached end of file
reached end of file
got data:
2
reached end of file
got data: 1
2
reached end of file

NB! if the file already exists prior to starting the app, everything works as expected

kicsikrumpli avatar Aug 24 '18 07:08 kicsikrumpli