Giter VIP home page Giter VIP logo

Comments (10)

klaemo avatar klaemo commented on August 16, 2024

Yep, I'm seeing the same behavior.

from watchify.

vitalybe avatar vitalybe commented on August 16, 2024

I am experiencing this behavior very consistently in a project in the following form:

  • Whenever a file is changed, watchify correctly updates the bundle
  • As soon as any file has a syntax error that causes my "on.error" handle to be called, the file is no longer watched.
  • If I update another file, without fixing the original error, the new file will also stop being watched
  • As soon as I fix all the syntax errors and changed still watched file, all the files become watched again

from watchify.

vitalybe avatar vitalybe commented on August 16, 2024

I've been debugging watchify a bit and what happens is the following:

  • On function invalidate (id) the file that caused the invalidation is stopped being watched: w.close();
  • The bundle, as it is being built, is emitting the dep event b.on('dep', function (dep) { which causes every file, that isn't already watched, to be watched again.
  • If an error occurs during the bundling of that file, the dep event is never called for it and so it is never watched again

Currently my best suggestion would be to remove the following code in the invalidate function:

    if (fwatchers[id]) {
        fwatchers[id].forEach(function (w) {
            w.close();
        });
        delete fwatchers[id];
        delete fwatcherFiles[id];
    }

Can anyone explain why does it exist in the first place? Why would we want to stop watching for files changes when a change is encountered?

from watchify.

johanfriis avatar johanfriis commented on August 16, 2024

I spent some time debugging this as well, and found a reproducible case:

node version: 0.10.21
watchify version: 0.10.2

$ echo "require('./middle'); console.log('index');" > index.js
$ echo "require('./end'); console.log('middle');" > middle.js
$ echo "console.log('end');" > end.js
$ watchify index.js -o b.js

The result of running node b.js is as expected

> end
> middle
> first

While watchify is running, write a syntax error to middle.js

$ echo "require('./end); console.log('middle';" > middle.js

Watchify and Browserify will as expected not re-bundle b.js, so the output of node b.js will be the same as before. However, middle.js has been removed from the list of watched files and any further changes to this file will not be registered. If we fix the syntax error and change the text logged, this results:

$ echo "require('./end); console.log('middle again');" > middle.js
$ node b.js
> end
> middle
> index

It seems the issue is with files (apart from the entry point) requiring other files. As @vitalybe mentions above, not removing the file from fwatchers solves this particular issue, but probably brings others with it :)
I will leave a pull request if I find a solution, but as of this moment I am not certain of a good one.

from watchify.

vitalybe avatar vitalybe commented on August 16, 2024

Since there was no further comments, I fixed it as I described above, by commenting out the fwatcher related code. Will report if I found any issues with that solution.

from watchify.

cconger avatar cconger commented on August 16, 2024

I made a fix to this problem with a slightly different solution. Instead of removing watchers I instead keep a map of files that changed since the last successful build. If an error occurs in the bundling phase I assume that the error was in one of those files and the watcher is reapplied.

The set of changed files gets reset if the end event is thrown and no error was grabbed off of the bundler.

Change is here: cconger@35407c0

from watchify.

nibblebot avatar nibblebot commented on August 16, 2024

@cconger nice, going to use your work in my fork :)

from watchify.

mattdesl avatar mattdesl commented on August 16, 2024

We're experiencing the same problem. Saving another file after fixing the syntax error will continue the watch task as normal...

from watchify.

st0nerhat avatar st0nerhat commented on August 16, 2024

I'm using tsify with watchify and confirm that I see the same behavior described by mattdesl

from watchify.

zertosh avatar zertosh commented on August 16, 2024

This isn't a problem anymore. If this issue persists, please open a new issue.

from watchify.

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.