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

[v2] Configure awaitWriteFinish for chokidar #5758

Merged
merged 2 commits into from
Oct 13, 2021
Merged

Conversation

bradlc
Copy link
Contributor

@bradlc bradlc commented Oct 11, 2021

This PR configures the awaitWriteFinish setting for chokidar.watch. From the chokidar documentation:

[...] in some cases some change events will be emitted while the file is being written. In some cases, especially when watching for large files there will be a need to wait for the write operation to finish before responding to a file creation or modification.

The exact settings (stabilityThreshold: 50, pollInterval: 10) are based on those used by postcss-cli: https://github.com/postcss/postcss-cli/blob/master/index.js#L125-L128

When looking into #5753 I observed that occasionally a file read will return an empty string on Windows, even when the file has contents. This can cause new classes to be missed. Configuring awaitWriteFinish helps to avoid this by delaying the change event until the file size has not change for 50ms. I was not able to reproduce the empty string issue with awaitWriteFinish configured as per this PR.

@bradlc bradlc merged commit a3049e6 into v2 Oct 13, 2021
@bradlc bradlc deleted the v2-await-write-finish branch October 13, 2021 16:17
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

Successfully merging this pull request may close these issues.

1 participant