-
-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Proof of Concept] Move from chokidar
to sane
.
#41
Conversation
Tests are failing on OS X. I'll see if I can get access to a Mac or something to test. |
@wtgtybhertgeghgtwtg, the tests on master are also failing on OS X (don't know if it's the same problem). That said, it would be awesome if you can fix that. I'll start testing this soon. |
Okay a first round of real-world testing:
However I noticed one issue on both tests: if I import a module that does not exist, it throws an error and exits the process.
In my entry file I did Furthermore, the |
To make |
That might be a problem. |
That was causing tests to fail, at least on my machine. I can do something like what |
Aha, I had hoped |
|
Is there a test for this? What is the expected behavior? |
Apparently there isn't a test for this, maybe in the webpack/webpack repo there is but I doubt it. The expected behavior is that when I import a non-existent module in my entry file (
Note that the watch process keeps running (which it should). After applying this PR, the process stops immediately:
The module |
I'm sorry, could you provide a repo showing this error? I'm having trouble reproducing it. |
|
@wtgtybhertgeghgtwtg sorry for the delay. I have created an example repo for you with instructions how to reproduce it. It seems to be also happening in other modes. |
Thank you. It looks like it's because |
@SpaceK33z what platform/node version are you running? Possibly related, webpack seems to totally bug out and try to watch everything if you try to import a nonexistent module. Adding a
Strangely, for me on Mac and linux, it doesn't attempt to watch |
@romanzenka awesome, so do I understand it correctly that you previously had to use polling mode because otherwise file change detection wouldn't work, but after this PR you don't even need to use polling mode anymore? That would be a really great benefit :). |
@SpaceK33z Yes, that's what I am saying. Let me do a bit more research though to make sure that the fix was not due to something else I changed instead of just the Chokidar -> Sane switch. |
@SpaceK33z Confirmed. I removed the patched version of watchpack and Windows went back to ignoring saves to files in my IDE (IntelliJ). Interestingly enough, if I do 'git revert', that change gets noticed properly. |
This commit fixed the problem of not detecting IntelliJ's 'safe write'. The fix is available since watchpack 1.1.0. So Webpack 2.0 (that depends on watchpack 1.2.0) + webpack-dev-server do not have any problems with IntelliJ IDEA. As I understand, watching package doesn't matter, it works well both with chokidar and sane. |
Just a testimony, I have been digging into the watchpack source code and really think it needs a revamp. I also had the strangest problem running webpack in watch mode and trying running it in the JVM: segfaults when using chokidar and no problem running sane. So I'm endorsing this PR 100%. I also noticed concurrency problems when running tests with high speed rewrites of watched files. |
I agree, but that's out of the scope of this PR. I was planning on proposing a rewrite (and a |
Codecov Report
@@ Coverage Diff @@
## master #41 +/- ##
==========================================
- Coverage 94.98% 91.64% -3.35%
==========================================
Files 3 3
Lines 339 323 -16
Branches 85 72 -13
==========================================
- Hits 322 296 -26
- Misses 17 27 +10
Continue to review full report at Codecov.
|
atomic: false, | ||
alwaysStat: true, | ||
ignorePermissionErrors: true, | ||
this.watcher = sane(directoryPath, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to this repro repo it seems like this can be called with non-directory or a non-existent directory. Sane will have to throw an error here because it's an obvious user error to call sane on a non-directory. See my comments:
- Do not throw on missing directory/file. amasad/sane#87
- Swallow ENOENT and ENOTDIR errors for
fs.watch
. amasad/sane#88
Looking at the stack from the repro repo I think you should filter the files before mapping them to the watcherManager
in watchpack.js
which seems like it will solve the problem for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're completely right and I'm kinda embarrassed that I didn't figure that out earlier.
I wrote a cheap one-line filter for this and it worked. I'll see if I can get a more efficient one hammered out by tomorrow.
This latest commit brings good news and bad news. |
Friendly reminder about wtgtybhertgeghgtwtg/watchpack#1 I think you've still got some hidden issues in this PR, which may or may not be exposed by the tests. For ex, these Plus it has watchman =) |
Fix sane
The problem is that the failing tests rely on watching a file that doesn't exist yet. @SpaceK33z, is |
@wtgtybhertgeghgtwtg I don't know, I'm only managing the issues / PR's for this repo a bit. However, if that test succeeded before, it should keep working 😄. |
The tests that are failing are |
Well let's think about it - under which circumstance would you want Watchpack to trigger rebuild on a file that was freshly created? When I am splitting a file into two, I can easily delete one half of file A, save, create file B, save. If Watchpack does not notice that file B appeared, it will be stuck on the failed compile with one half of A. So I would argue that being able to notice file being created is important. |
Why would it need to watch file B, specifically, before it existed? What if I had named it file C? |
@wtgtybhertgeghgtwtg, perhaps @TheLarkInn or @sokra can you give more info about this. |
Well just think what we are trying to accomplish here. "If source code changes, recompile". Source code can change by people modifying files, creating files or deleting files. The mental model is "If I change it, recompile will trigger". If you do not notice files being created, as a programmer I will have to think "After I add this file I must remember to modify some other file that already existed for no reason, otherwise recompile will not trigger". |
Consider this scenario:
If you can't watch non-existing files it would not detect adding of file B. |
How about creating a new major version of
it'd be
|
Hi everyone. I see a good discussion going on here. However it seems to have died February 23rd. So what should we do now? |
Proposed to close #36.