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

Change event is only triggered twice when watching one file #556

Closed
lonelywolf4git opened this issue Nov 22, 2016 · 6 comments
Closed

Change event is only triggered twice when watching one file #556

lonelywolf4git opened this issue Nov 22, 2016 · 6 comments

Comments

@lonelywolf4git
Copy link

I want to watch file and only handle change event, but it is only triggered twice, when I change the watched file with third time, it can not handle change event, my code is here:

var chokidar = require('chokidar');
var path = require('path')
function registerFileChangeListener()
{
let testfile= path.join(__dirname, '../test.txt')
let watcher = chokidar.watch(testfile)
watcher.on('change',(path,stats)=>
{
console.log(path +' is changed')
})
}
registerFileChangeListener()

But it can fix this issue by adding
{
usePolling:true
}
I am not sure why this happen.

@birjj
Copy link

birjj commented Nov 22, 2016

Cannot reproduce on Windows 7.1, Node 6.9.1, Chokidar 1.6.1

@lonelywolf4git
Copy link
Author

I do not try on windows. but it happens on Ubuntu

@birjj
Copy link

birjj commented Nov 22, 2016

Also cannot reproduce on Arch, Node 7.1.0, Chokidar 1.6.1.

Have you tried logging the raw events to see if chokidar is actually told of a change event? (and are you actually sure you're changing the file)

@steelbrain
Copy link

I have been hitting this error as of lately, I'm on v1.6.1 as well
The exact problem I'm hitting is that some files, with really long paths have their change events emitted twice. While files with shorter closer paths have their change event triggered only once.

@steelbrain
Copy link

My issue turned out to be an EMFILE one

@cactysman
Copy link

Experiencing that here.

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

5 participants