File chokidar-sample/watched/internal/external has been added
Initial scan complete. Ready for changes
Additional context
chokidar only checks ignoreInitial flag in _handleFile method (in nodefs-handler.js).
This event was emitted by _handleSymlink method here.
Adding initialAdd parameter to _handleSymlink, and using similar code to the one in _handleFile to emit EV_ADD solves this specific issue (but might introduce some more bugs).
I've encountered this bug while I was debugging weird pm2 behavior: one of our apps was always restarting immediately after being started. Turns out it was caused by one of the watched directories containing symlinks.
pm2 starts to listen to all events immediately after creating a chokidar instance, not waiting for ready event, apparently to improve startup performance (so that the app can be launched without waiting for chokidar to scan all watched directories). So it gets that add event from chokidar during chokidar's initial scan, and triggers the reload of the app (thinking that something have changed).
Describe the bug
EV_ADD (
add
) event is emitted for symlinks encountered inside watched directories during the initial scan, regardless ofignoreInitial
option.Versions (please complete the following information):
To Reproduce:
Expected behavior Expected output:
Actual output:
Additional context chokidar only checks
ignoreInitial
flag in_handleFile
method (innodefs-handler.js
). This event was emitted by_handleSymlink
method here. AddinginitialAdd
parameter to_handleSymlink
, and using similar code to the one in_handleFile
to emit EV_ADD solves this specific issue (but might introduce some more bugs).I've encountered this bug while I was debugging weird pm2 behavior: one of our apps was always restarting immediately after being started. Turns out it was caused by one of the watched directories containing symlinks.
pm2
starts to listen toall
events immediately after creating a chokidar instance, not waiting forready
event, apparently to improve startup performance (so that the app can be launched without waiting for chokidar to scan all watched directories). So it gets thatadd
event from chokidar during chokidar's initial scan, and triggers the reload of the app (thinking that something have changed).