Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unwatch produces NaN for last position #5

Open
erik-stephens opened this issue Jul 21, 2016 · 4 comments
Open

unwatch produces NaN for last position #5

erik-stephens opened this issue Jul 21, 2016 · 4 comments

Comments

@erik-stephens
Copy link
Contributor

unwatch() doesn't seem to work very well. I don't nodejs very well, so having a difficult time understanding the async.reduce() call. Maybe a name clash with start? For anything but the first iteration, start becomes undefined which causes this to go sideways.

$ cat dood.js
Tail = require('tail-forever');
tail = new Tail("/tmp/dood", {start: 0, bufferSize: 6});
tail.on("line", function(line) { });
tail.on("error", function(error) { console.log('ERROR: ', error); });
function unwatch() {
  console.log('POS:', tail.unwatch());
}
setTimeout(unwatch, 1000);

As long file is less than buffer size, seems ok...

$ echo foo > /tmp/dood
$ node dood.js
POS: { inode: 137561, pos: 4 }

but as soon as more than one chunk is read, the last known position goes NaN:

$ echo foobar > /tmp/dood
$ node dood.js
POS: { inode: 137561, pos: NaN }
@megastef
Copy link
Contributor

I think the .js file is generated by coffee script. It would be better to search the "bug" in the .coffee file. In this case it might help to "compile" the .coffee file again with the current version.

@mingqi will you maintain this repository and accept pull requests/publish to npm?

@megastef
Copy link
Contributor

I made some tests in my fork, and setting the option "bufferSize: -1", did not produce NaN.

@mingqi
Copy link
Owner

mingqi commented Jul 21, 2016

@megastef yes, I maintain this repository and accept PR to npm

@megastef
Copy link
Contributor

@mingqi Thank you very much for the quick merge!

@mingqi mingqi closed this as completed Jan 28, 2017
@mingqi mingqi reopened this Jan 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants