Skip to content

Improper handling of broken symlinks, causes UnhandledPromiseRejectionWarning #955

Closed
@jaens

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:

const linkPath = await fsrealpath(path);

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.

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions