tail-stream
tail-stream copied to clipboard
waitForCreate=true together with beginAt='end' results in file read from beginning on every change
as the title says
Is this still an issue? If so, could you please provide steps to reproduce? Thanks
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:
- if exists, remove
nope.txt
-
node index.js
- create
nope.txt
- add one line and save
- 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