Comments (10)
Yep, I'm seeing the same behavior.
from watchify.
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.
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.
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.
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.
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.
@cconger nice, going to use your work in my fork :)
from watchify.
We're experiencing the same problem. Saving another file after fixing the syntax error will continue the watch task as normal...
from watchify.
I'm using tsify with watchify and confirm that I see the same behavior described by mattdesl
from watchify.
This isn't a problem anymore. If this issue persists, please open a new issue.
from watchify.
Related Issues (20)
- Update to browserify 16 HOT 1
- Transforms & Watchify - co-exist how? HOT 3
- Please update dependencies for security issues HOT 3
- Update event not triggered every save (called every 3 saves...)
- Getting multiple events from single update in REST call
- Feature Request: Add --help command line flag
- watchify : 无法将“watchify”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:1 字符: 1 HOT 1
- Vulnerabilities in dependencies? HOT 4
- Watchify doesn't accept multiple file args as browserify does.
- Silent freeze if source imports non-existant module HOT 6
- Watchify does not recognise changes with transform (babelify)
- Frequent test failures
- Triggers install errors with Node 12 & 13 HOT 5
- watchify is brilliant especially with tsify
- SOLVED, DISREGARD :) parsing error when creating bundle.js HOT 1
- I am getting the following error when I try to parse the following code "http://lib.upon.one"
- Watchify is not detecting changes HOT 3
- [Security] bump chokidar HOT 1
- browserify fails while reading node_modules folder
- Error: EBUSY: resource busy or locked, open 'D:\my-project\source\js\bundle.js'
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 watchify.