Skip to content
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

[Solved: Upgrade to Rails 6] Spring app starts to use 100% CPU after I run some specs #608

Closed
ndbroadbent opened this issue Dec 7, 2019 · 0 comments

Comments

@ndbroadbent
Copy link
Contributor

ndbroadbent commented Dec 7, 2019

Posting for posterity / Google indexing

I'm using Rails 5.2.3, Spring 2.1.0, spring-watcher-listen 2.0.1, on macOS Catalina 10.15.1.

The spring app process starts using 99%-100% CPU after I run some specific tests. I started spring server, and found this in the logs:

[2019-12-07 23:35:43 +0700] [63351] [application:test] forked 63361
[2019-12-07 23:35:43 +0700] [63316] [application_manager:test] got worker pid 63361
        ** ERROR: directory is already being watched! **

        Directory: /path/to/my/app/node_modules/puppeteer/.local-chromium/mac-686378/chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/78.0.3882.0

        is already being watched through: /path/to/my/app/node_modules/puppeteer/.local-chromium/mac-686378/chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/78.0.3882.0

        MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
        ** ERROR: directory is already being watched! **

        Directory: /path/to/my/app/node_modules/puppeteer/.local-chromium/mac-686378/chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/Current/Resources

        is already being watched through: /path/to/my/app/node_modules/puppeteer/.local-chromium/mac-686378/chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/78.0.3882.0/Resources

        MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
        ** ERROR: directory is already being watched! **

        Directory: /path/to/my/app/node_modules/puppeteer/.local-chromium/mac-686378/chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/Current/Libraries

        is already being watched through: /path/to/my/app/node_modules/puppeteer/.local-chromium/mac-686378/chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/78.0.3882.0/Libraries

        MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
        ** ERROR: directory is already being watched! **

        Directory: /path/to/my/app/node_modules/puppeteer/.local-chromium/mac-686378/chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/Current/Internet Plug-Ins

        is already being watched through: /path/to/my/app/node_modules/puppeteer/.local-chromium/mac-686378/chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/78.0.3882.0/Internet Plug-Ins

        MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
        ** ERROR: directory is already being watched! **

        Directory: /path/to/my/app/node_modules/puppeteer/.local-chromium/mac-686378/chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/Current/XPCServices

        is already being watched through: /path/to/my/app/node_modules/puppeteer/.local-chromium/mac-686378/chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/78.0.3882.0/XPCServices

        MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
        ** ERROR: directory is already being watched! **

        Directory: /path/to/my/app/node_modules/puppeteer/.local-chromium/mac-686378/chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/Current/Helpers

        is already being watched through: /path/to/my/app/node_modules/puppeteer/.local-chromium/mac-686378/chrome-mac/Chromium.app/Contents/Frameworks/Chromium Framework.framework/Versions/78.0.3882.0/Helpers

        MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
[2019-12-07 23:36:05 +0700] [63351] [application:test] 63361 exited with 0

So it seems like this is potentially the same issue as rails#32700 - "lot of 'is already being watched through' messages when using rails console if using node_modules"

The strange thing is that these specs don't use puppeteer or Chromium. These errors also don't appear when I run a lot of other specs, and the 100% CPU usage doesn't happen. So I'm not sure why some specific specs are causing node_modules to be watched.

I read through the wiki article for "Duplicate directory errors", and it sounds like this could be the cause for the high CPU usage.

I found rails#33822 - "Do not watch parent directory of dirs". This sounds promising! I saw that this commit never made it into the 5-2-stable branch, so it's not available in my current version of Rails: 5.2.3.

So it sounds like this issue will be solved after I upgrade to Rails 6. I just wanted to post this issue so that Google will pick it up, in case anyone else runs into it on Rails 5.x.

Related issues:

@ndbroadbent ndbroadbent changed the title [Solved] Spring app starts to use 100% CPU after I run some specs that watch some strange directories [Solved - Upgrade to Rails 6] Spring app starts to use 100% CPU after I run some specs that watch some strange directories Dec 7, 2019
@ndbroadbent ndbroadbent changed the title [Solved - Upgrade to Rails 6] Spring app starts to use 100% CPU after I run some specs that watch some strange directories [Solved - Upgrade to Rails 6] Spring app starts to use 100% CPU after I run some specs Dec 7, 2019
@ndbroadbent ndbroadbent changed the title [Solved - Upgrade to Rails 6] Spring app starts to use 100% CPU after I run some specs [Solved: Upgrade to Rails 6] Spring app starts to use 100% CPU after I run some specs Dec 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant