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

No way to catch errors if file do not exists or renamed #16

Closed
LeoIannacone opened this issue Mar 24, 2014 · 2 comments
Closed

No way to catch errors if file do not exists or renamed #16

LeoIannacone opened this issue Mar 24, 2014 · 2 comments

Comments

@LeoIannacone
Copy link

Hi all,

there's no way to catch exception coming from "file not exists" error or "rename" events ?

This test crashes everytime. And I am not able to control exceptions.

var Tail = require('tail').Tail
  , exec = require('child_process').exec

exec('echo hello world 0 >> file.txt')

tail = new Tail('file.txt')

tail.on("line", function(data) {
    console.log(data);
});

setTimeout(function() {
  exec('echo hello world 1 >> file.txt')
}, 1000)

setTimeout(function() {
  exec('mv file.txt old.txt')
}, 1500)

setTimeout(function() {
    echo('echo hello world 2 >> file.txt')
}, 3000)

It looks like problem comes from:

    else if e is 'rename'
      @unwatch()
      setTimeout (=> @watch()), 1000

you may need to check if file exists before call @watch ... if it does not exist, call setTimeout and check again.

@LeoIannacone LeoIannacone changed the title No watch to carch errors if file do not exists or renamed No way to carch errors if file do not exists or renamed Mar 24, 2014
@LeoIannacone LeoIannacone changed the title No way to carch errors if file do not exists or renamed No way to catch errors if file do not exists or renamed Mar 24, 2014
@lucagrulla
Copy link
Owner

Currently the library doesn't handle this scenario. Feel free to send a pull request :-)

On a side note: I guess it's note enough to just setTimeout. There's at least the need of a circuit breaker at some stage that will throw an exception and stop the library otherwise you go in an infinite -and probably not particularly useful- loop.

@lucagrulla
Copy link
Owner

release V1.0.0 is addressing the problem with an extra optional parameter that will disable the tail -F behaviour.

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

Successfully merging a pull request may close this issue.

2 participants