Skip to content
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

Failing to detect file changes after the second save #1399

Open
SteffenBlake opened this issue Dec 30, 2024 · 2 comments
Open

Failing to detect file changes after the second save #1399

SteffenBlake opened this issue Dec 30, 2024 · 2 comments

Comments

@SteffenBlake
Copy link

SteffenBlake commented Dec 30, 2024

Describe the bug

When watching a directory, .on('watch', ...); fails to trigger after a file is saved for the second time onwards, but it does properly trigger when saved the first time.

However, .on('raw', ...) does trigger.

Versions (please complete the following information):

  • Chokidar version: 4.0.1
  • Node version: 18.18.0
  • OS version: Windows 11

To Reproduce:

Steps to reproduce the behavior. Include filename and chokidar config.

import chokidar from 'chokidar';
const watcher = chokidar.watch(
    "some/dir",
    {
        ignoreInitial: true,
        awaitWriteFinish: true,
        cwd: "some/dir",
        usePolling: true // Tried this with false and true, didnt impact behavior
    }
);

watcher.on('change', onChange);
watcher.on('raw', onRaw);

onChange(fileName: string) {
    console.log(`Chokidar: file changed - filename:"${fileName}"`);
}
onRaw(e: string, fileName: string) {
    console.log(`Chokidar: raw - event:"${e}", filename:"${fileName}"`);
}

Then have a file in some/dir, open and edit it, make a change and save, then make a change and save again.

Expected behavior
Both onChange and onRaw trigger twice, with onRaw logging a "change" event specifically each time

Actual Behavior
Both onChange and onRaw trigger as expected on the first modification+save.

On the second modification+save, only onRaw triggers logging a "change" event, but no matching onChange event is triggered.

Additional context
This is specifically being observed with Adobe Acrobat editing a pdf, but I believe the issue is present for any type of file and editor on windows 11. I havent tested other OS/Editor/Filetype options yet.

@SteffenBlake
Copy link
Author

Updated Node to v23.5.0(latest) to test, issue still persists the same

@43081j
Copy link
Collaborator

43081j commented Jan 3, 2025

I'm struggling to reproduce this

especially because your cwd is the same as the directory you're watching, in your example

that leads to all sorts of chaos. if I remove the cwd, it works as expected, otherwise I get a whole bunch of unrelated wackiness (which may be another thing to look into separate to this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants