-
-
Notifications
You must be signed in to change notification settings - Fork 586
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
Intermittently losing an 'add' file event with nodefs-handler.js #685
Comments
Just to make sure, have you inspected output to the If so, then your finding appears feasible, and the solution may be as simple as tweaking the throttle methodology. Perhaps it should be more of a debounce with both leading and trailing invocation. |
I did verify that an fs.watch event is emitted for the file that was missed, yes. Debouncing with a leading/trailing invocation does seem like the right solution. I'm not seeing that as a particularly "simple" task here, but it might just be because I don't understand the code as well as you. Does that seem like something you could (and would be willing to) put together quickly? Or should I see what I can come up with? |
On Windows, I'm using chokidar to monitor a single flat folder that is receiving photos being taken by a camera, and about once every 20 or 30 photos an 'add' event ends up lost.
I've added a whole bunch of logging to chokidar and node's fs.js module, and I think I've narrowed down the problem to receiving the fs event while chokidar is running
readdirp
. It's possible that my understanding of how chokidar is working is incorrect, so I wanted to post this to get a second opinion before I look into a fix.Inside of
nodefs-handler.js
_handleDir
read
function, there's some code that bails ifreaddir
is already being called:I believe this causes chokidar to essentially ignore any events that're happening while readdir is still running. On my windows machine with this particular folder of images,
readdirp
is taking about 30ms to run. My current understanding is that the fs event that would indicate my photo has been added is occurring within that ~30ms window and being ignored, and thatreaddirp
is for whatever reason not returning it in its list of files. I can't imagine that readdirp can guarantee that its list of files is correct if they're changing out from underneath it mid-call.If all of that sounds plausible to someone who knows the code pretty well, then I'd be happy to look into fixing it.
Thanks!
The text was updated successfully, but these errors were encountered: