Giter Site home page Giter Site logo

Comments (16)

vojtajina avatar vojtajina commented on August 25, 2024

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.

paulmillr avatar paulmillr commented on August 25, 2024

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.

vojtajina avatar vojtajina commented on August 25, 2024

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.

paulmillr avatar paulmillr commented on August 25, 2024

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.

amj avatar amj commented on August 25, 2024

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.

paulmillr avatar paulmillr commented on August 25, 2024

Just updating current status: you can use fs.watch currently with option, but it is much more unreliable.

from chokidar.

es128 avatar es128 commented on August 25, 2024

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.

paulmillr avatar paulmillr commented on August 25, 2024

not sure it will solve the problem

from chokidar.

cesutherland avatar cesutherland commented on August 25, 2024

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.

es128 avatar es128 commented on August 25, 2024

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.

cesutherland avatar cesutherland commented on August 25, 2024

🤘

from chokidar.

jugheadjones10 avatar jugheadjones10 commented on August 25, 2024

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.

paulmillr avatar paulmillr commented on August 25, 2024

@jugheadjones10 there is no point in asking this question a person from 2015.

from chokidar.

jugheadjones10 avatar jugheadjones10 commented on August 25, 2024

@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.

cesutherland avatar cesutherland commented on August 25, 2024

2015 was pretty dope tho

from chokidar.

paulmillr avatar paulmillr commented on August 25, 2024

@cesutherland in some way, yes

from chokidar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.