paulmillr / chokidar

Minimal and efficient cross-platform file watching library

Home Page:https://paulmillr.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mac: Add event on non-existing file never fires if the path contains symlinked directories

hkratz opened this issue · comments

Describe the bug

On macOS: While watching a non-existing file when the parent directory exists and the parent directory path contains symlinks the add event is not fired when the file is created.

This works fine on Linux. It also works fine if the parent directory path contains no symlinks.

Versions (please complete the following information):

  • Chokidar version 3.5.3
  • Node version v16.16.0
  • OS version: macOS 12.5.1 arm64

To Reproduce:

Run sample program:

import { mkdir, symlink, writeFile } from 'fs/promises';
import * as chokidar from 'chokidar';
await mkdir("root");
await mkdir("root/watched");
await symlink("root", "link");
let watcher = chokidar.watch("link/watched/file").once('add', () => {
    console.log("watcher: file created");
    void watcher.close();
});
await new Promise(f => setTimeout(f, 1000));
await writeFile("link/watched/file", "sample content");
console.log('file written.');

Expected behavior
watcher: file created should be printed.