Git Product home page Git Product logo

Comments (3)

iangreenleaf avatar iangreenleaf commented on June 21, 2024

Do you mean it's no longer recursively watching everything in a directory? It was working at some point - we couldn't always get the exact filename that had changed, but could at least detect change events.

I would like to unify the system calls. I'm hesitant though because as noted in nodejs/node-v0.x-archive#2049, it's not totally clear which option is preferred - the core guys stated at one point that watchFile will be going away, and the docs instruct you to use watch when available. But watch still has some bugs and doesn't always pass a filename, which would be a problem for a couple of our features. And just to compound matters, it's unclear from the docs if watchFile makes use of inotify etc when available, or if it is a purely polling solution (at one point it was using inotify, but maybe that's only happening in watch now).

So my point is that neither of the options looks totally great to me right now. Thoughts?

from node-supervisor.

heycalmdown avatar heycalmdown commented on June 21, 2024

As you know node-supervisor watch the root directory only via fs.watch on Windows. And according to the implement of the fs.watch the fourth option is FALSE that means ReadDirectoryChangesW doesn't watch files recursively at all.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365465(v=vs.85).aspx

Not just leaking exact filename, but leaking the event too.

I can understand why the implementation of fs.watch use the option, because making too big size of buffer for watch huge number of files leads to get the BSOD. And also understand your concern about polling many files with fs.watchFile.

So here is my thought: seek directories recursively like non-windows implementation and watch directory only not each files.

pseudo code:

var findAllWatchFiles = function(dir, callback) {
  dir = path.resolve(dir);
  if (ignoredPaths[dir])
    return;
  fs.stat(dir, function(err, stats){
    if (err) {
      util.error('Error retrieving stats for file: ' + dir);
    } else {
      if (stats.isDirectory()) {
        if (isWindows) callback(dir);
        fs.readdir(dir, function(err, fileNames) {
          if(err) {
            util.error('Error reading path: ' + dir);
          }
          else {
            fileNames.forEach(function (fileName) {
              findAllWatchFiles(dir + '/' + fileName, callback);
            });
          }
        });
      } else {
        if (!isWindows && dir.match(fileExtensionPattern)) {
          callback(dir);
        }
      }
    }
  });
};

from node-supervisor.

iangreenleaf avatar iangreenleaf commented on June 21, 2024

Closed by #70.

from node-supervisor.

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.