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

Change event is not emitted on Windows when continuously appending to an initially existing file #1297

Open
bersbersbers opened this issue Jan 14, 2024 · 2 comments

Comments

@bersbersbers
Copy link

I see the same thing as #999 on Windows. Essentially, I get only one or two (initial/final) change events for a file despite continuously appending to it. I see the same kind of issues in real life, e.g., VS Code auto-updates of output from https://github.com/pkolaczk/fclones on Windows are stalled until re-focusing VS Code (compare microsoft/vscode#93277).

To reproduce, I used the same code for index.js as #999 (comment), and

Continuously append to an existing file

echo 1 > output.log
ping -n 2 0.0.0.0
(for /l %f in () do @echo 1) >> output.log

(Without the ping, which emulates a sleep on Windows, it works sometimes, and sometimes not.)

Interestingly, the problem is resolved by Ctrl-C'ing node and restarting the above index.js - so events seem to be generated, but chokidar seems to choke on them somehow.

Also, the issue does not reproduce with either of the following variants:

Continuously append to an initially missing file (hence creating it first)

if exist output.log del output.log
(for /l %f in () do @echo 1) >> output.log

Continuously write to a new file

(for /l %f in () do @echo 1) > output.log

Create a new file in each loop iteration

for /l %f in () do @echo 1 > output.log

Append to a file in each loop iteration

for /l %f in () do @echo 1 >> output.log

[email protected], node v20.8.0, Windows 10 22H2, cmd.exe

@bersbersbers
Copy link
Author

Two more notes:

the problem is resolved by Ctrl-C'ing node ...

This is not supposed to mean that chokidar is hanging. It is processing subsequent events just fine if not terminated.

@Matsuuu
Copy link

Matsuuu commented Jan 19, 2024

I experienced something similiar. I've got a dockerized environment running on windows, that uses chokidar to watch for file changes. The events don't trigger on the dockerized environment, causing updates not to flow through.

Using usePolling: true helped for me though

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