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
Remove spring-watcher-listen
from default Gemfile
#36377
Remove spring-watcher-listen
from default Gemfile
#36377
Conversation
`spring-watcher-listen` watch application root by default. https://github.com/jonleighton/spring-watcher-listen/blob/c4bfe15805867e229588e4b776a7b87438137094/lib/spring/watcher/listen.rb#L58 This is necessary to watch the file (e.g. `.ruby-version`) in the application root. By this `node_modules` also be watched, and it is a possibility to be shown a warning by `listen`. Related to rails#32700, rails#34912, rails/webpacker#1990. `listen` watches directory recursive by default, and it cannot avoid it. guard/listen#111 So If this warning happens, the only workaround the user can do is remove the gem. The issue is likely to occur more frequently in Rails 6 because `rails new` runs `webpacker:install` by default. Because of such a state, I think that we should not recommend to use `spring-watcher-listen`. Spring has polling watcher, restart process works without this `spring-watcher-listen`. Because of polling base, CPU load may be higher than listen base. Still I think that it is better than the warning comes out.
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.
Looks good to me, who added it? Can we bring them in on the discussion?
Hey, quick heads up. Reason was performance in large projects, where walking the project tree constantly may not be cheap. Think Shopify. Same reason Rails introduced reloading based on |
In principle, as a first thought, I think I'd open an issue in the gem to discuss it. WDTY? |
Unfortunately, Listen's ignore option does not really ignore directories. The directories are still watched by the native adapter, and events are only filtered after they are fired. Therefore, properly specifying the ignore option does not solve this issue. |
Thanks for your description. In my understanding, the role of spring watcher is to watch only files that want to monitor for a restart of spring. As this is only a part of the files such as |
@y-yagi removing Removing However, see this branch of my example app where Show repro
|
Hey, need to work on a presentation for tomorrow, I'll eventually come back to this issue. |
@jordan-brough Thanks for your report.
|
Currently, `clear_cache_if_necessary` is executed even if view paths are not set like `rails console`. If the watcher class is `EventedFileUpdateChecker` and the watch directories are empty, the application root directory will watch. This is because listen uses the current directory as the default watch directory. https://github.com/guard/listen/blob/8d85b4cd5788592799adea61af14a29bf2895d87/lib/listen/adapter/config.rb#L13 As a result, `node_modules` also watch. This cause a warning of `listen`. Ref: rails#36377 (comment)
I don't know much about |
I tried to implement this, maybe can do. y-yagi/spring-watcher-listen@c3c697d |
If this by default will increase CPU why should not we remove it? I think the benefits that it may bring doesn't overweight the problems that it will cause. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
@y-yagi is there a reason to keep the |
Yes. It is for the evented file updater. |
See rails/rails#36377 for upstream removal.
spring-watcher-listen
watch application root by default.https://github.com/jonleighton/spring-watcher-listen/blob/c4bfe15805867e229588e4b776a7b87438137094/lib/spring/watcher/listen.rb#L58
This is necessary to watch the file (e.g.
.ruby-version
) in the application root.By this
node_modules
also be watched, and it is a possibility to beshown a warning by
listen
.Related to #32700, #34912, rails/webpacker#1990.
listen
watches directory recursive by default, and it cannot avoid it.guard/listen#111
So If this warning happens, the only workaround the user can do is remove the gem.
The issue is likely to occur more frequently in Rails 6 because
rails new
runswebpacker:install
by default. Because of such a state, I think that we should not recommend to usespring-watcher-listen
.Spring has polling watcher, restart process works without this
spring-watcher-listen
. Because of polling base, CPU load may be higher than listen base. Still I think that it is better than the warning comes out.