Comments (16)
Ok, I looked into it a bit...
The "directory watcher" (when the file is added back) is ignored because of this condition https://github.com/paulmillr/chokidar/blob/master/src/index.coffee#L120 (the timestamps as the same).
So it does not fire the callback, that would compare the content. If I remove this condition, it works fine.
We don't wanna remove this condition, that would mean a lot of unnecessary operations. Is there anything else we could quickly compare, instead of mtime ? Or maybe we could keep this condition for files and always fire the callback for directories and try to optimize the comparison a bit (https://github.com/paulmillr/chokidar/blob/master/src/index.coffee#L144-L162).
from chokidar.
moreover, removing of the condition will lead to many bugs. did this in the past. mtime is the most useful stuff.
optimising comparing of file trees seems to be cooler solution.
from chokidar.
Well, optimizing the comparison won't fix it - that's in addition to removing the condition for directories.
What bugs would this lead into ?
from chokidar.
I don’t remember exactly, but there was some cross-platform issues, events were not emitted on windows / os x etc or emitted pretty shitty, not every time
from chokidar.
For people noticing this effect from using vim, the following addition to your .vimrc is a temporary workaround:
:set backupcopy=yes
(from the discussion on the previously closed issue here: karma-runner/karma#199)
from chokidar.
Just updating current status: you can use fs.watch
currently with option, but it is much more unreliable.
from chokidar.
Just throwing an idea out there, even though I haven't studied this too closely:
What if the remove operations were put behind a quick setTimeout, and then conditioned by a fs.exists check? Will anyone really be bothered by a (let's say) 50ms delay on the unlink event being fired?
from chokidar.
not sure it will solve the problem
from chokidar.
I believe this is the correct workaround for vim:
set nowritebackup
With this option, vim will write the buffer to the file directly instead of 1. write to backup, 2. delete original, 3. rename backup. This means risking data loss in the event of an IO error.
from chokidar.
95c6dfc solves this for fsevents, 8f41a70 solves it for polling. The fs.watch
method seemed to work for this situation already.
Duplicate change events may still happen, but with vim I've observed them happening anywhere between 30ms and 500ms apart from each other, so I don't think it's reasonably possible or desirable to suppress them, since it's an accurate reflection of what's happening with the file.
from chokidar.
🤘
from chokidar.
Hi @es128 , I was using Tailwindcss, which uses Chokidar, and I came across this same problem. Is there a possibility that this issue isn’t resolved yet? Thanks.
from chokidar.
@jugheadjones10 there is no point in asking this question a person from 2015.
from chokidar.
@jugheadjones10 there is no point in asking this question a person from 2015.
@paulmillr Then can I direct it to you instead? Thanks! If needed I might be interested in creating a PR for this.
from chokidar.
2015 was pretty dope tho
from chokidar.
@cesutherland in some way, yes
from chokidar.
Related Issues (20)
- Folder rename is not reported when using a pattern HOT 2
- Received an unknown event from `fsevents` then watcher fired `unlink` event for the directory recursively HOT 7
- stat fails on invalid symbolic link - should use lstat
- Watching based on glob triggers on irrelevant files
- [v2: Vulnerability] Chokidar v2 is using glob-patern v3 which has a vulnerability HOT 5
- change event triggers even if file didnt change. HOT 2
- change event doesn't work after unlink HOT 2
- Node fs native recursive on Linux HOT 1
- Consider deduping entries passed to watch()
- Not Detecting New Files on External Drive in macOS HOT 3
- Change event is not emitted on Windows when continuously appending to an initially existing file HOT 2
- Incompatibility of types with recent changes in `@types/node` HOT 8
- consider switching to brace-expansion HOT 10
- Will there be a new release? HOT 1
- Looking for new contributors and maintainers HOT 10
- Failing unit tests on clean master HOT 5
- synchronous issues when using database operations when 'add' function is triggered
- Rename folder with files sends first unlinkdir and then unlink for all files
- Windows move command failed to move multi-level directories during chokidar monitoring
- Help!!! Chokidar watch not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chokidar.