Improper handling of broken symlinks, causes UnhandledPromiseRejectionWarning #955
Closed
Description
When watching a directory with followSymlinks
off, if the directory contains links for which the target does not exist, chokidar blows up with:
UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat <path of symlink>
This is due to calling fsrealpath
on the link, which fails (since the link target does not exist) here:
chokidar/lib/nodefs-handler.js
Line 416 in 7c79e45
Note the node.js documentation for fs.realpath
:
Asynchronously computes the canonical pathname by resolving ., .. and symbolic links.
(it does not specify what happens when the link target does not exist, but as reality shows it throws ENOENT
...)
Perhaps using the fs.readlink
function would be more appropriate there.