-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
refactor(watch): create single watcher for whole process #8083
refactor(watch): create single watcher for whole process #8083
Conversation
https://github.com/denoland/deno/pull/8083/checks?check_run_id=1295812207#step:15:1313 It might be a problem with |
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.
@magurotuna I'd be cautious about downgrading notify
- we also use it in Deno.fsEvents
and it might be pretty hard to replace it. Could you elaborate what's the problem you're experiencing?
Oh, I didn't notice |
On the other hand, if I hit
In the current implementation, we treat |
For now, I have added 10ms sleep to avoid a hot loop, referring to #7612 (comment) |
Discussed offline with @magurotuna and @caspervonb. Given bugs in watcher implementation we decided to postpone this PR and rewrite watcher properly. |
LGTM, doesn't seem to spike above 1% |
The remaining issue I'm digging into is that we get multiple consecutive "Watcher File changed detected! Restarting!" message. @bartlomieju gave me information about it. terminal
How to reproduce
import { a } from "./test2/a.js";
import { b } from "./test2/b.js";
import { c } from "./test2/c.js";
console.log(a);
console.log(b);
console.log(c);
console.log("hello world");
|
I gave it a try to reproduce it. On my main machine, where Manjaro 20.1.2 is running, the output I saw looks like: Well, actually the watcher didn't anything at all when I ran To see more detail, I inserted I also tried it on macOS. The result is almost identical, except for the events' kind which I think doesn't matter. |
Talked with @bartlomieju about the above issue, and it turned out that the watcher actually works as we expect. So this PR is ready to be merged. |
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.
LGTM, thanks @magurotuna, @bartossh, @caspervonb, this is a great improvement
This commit rewrites file watcher used with --watch flag. Instead of creating new watcher after each restart, only a single watcher is created for whole process. Additionally debouncing mechanism has been added to prevent infinite restart loops if multiple files were changed in quick succession. Co-authored-by: bartossh <[email protected]>
This is a follow-up PR to #7612
Fixes small part of #7465, so that we won't create file watcher every time on file updating.
When running
cargo run -- run --watch --unstable foo.js
and update the content offoo.js
, it seems like I've got results as expected.The integration test
run_watch
fails locally right now though. I'm looking into it.cc @bartlomieju