-
Notifications
You must be signed in to change notification settings - Fork 341
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
Spring hangs a lot #396
Comments
+1 also seeing a lot of hangs on OS X Yosemite. |
I'm on Linux Mint, though other users at our company are seeing it on Mac as well. Something as simple as changing branches can cause it:
|
Ctrl+C won't get me out of it, either. I have to kill the process from elsewhere. |
Yes, this is exactly my issue. When I log to a file by setting SPRING_LOG, then change branches, I see the above sequence of messages appear (
|
This is happening to me as well. For now I've added a post-checkout hook to call |
I am also experiencing this problem. I have to kill Spring processes that are consuming a lot of CPU even though |
+1 Spring status says Spring is not running (because I stopped it), but ps shows Spring processes still going. |
+1 Can confirm switching branches in our app (which has "a lot" of stuff in |
After a lot of tinkering I was able to figure out why it happens, at least in my case. First, Spring hangs when checking out a branch that has changes in one of the monitored files: |
@jafrog can you point to the line of code where spring hangs? |
@jonleighton For me it was here, right when Rails app is loaded |
Looks like the bug was related to |
Hmm, I'm still seeing some hangs. I just changed branches and ran
|
Even on a brand new Rails project, I still see orphaned Spring 'app' processes hanging around, sipping around 6% CPU. I have to In an older (Rails 3) project, I see the same thing but with git branch I get orphaned 'server' processes too. (This is on OS X Yosemite) |
Also saw that but was never able to reproduce
|
One of two times it hangs on El Capitan |
We're still seeing spring hanging a lot both on Linux and Macos. |
I did a bunch of debugging today on an app where spring was nearly unusable and it turns out that removing the |
Happening to me on mac as well. I run from guard and sometimes spring will hang - even after restarting guard I won't get any results back until I issue "spring stop". Might be loosely correlated with when I cancel tests that are running using ctrl+C (which I'm not sure how guard passes through to spring). Guard also has a bug where ctrl+c will stop the tests running, but also stop guard from watching any files, but that's not related to you... |
I can confirm that the |
@aaronchi we're still seeing a bunch of hangs, but aren't using dnsruby. Would you be able to share how you were debugging this? Thanks! |
You can try my fix: #484. It should help with hanging |
* Configure all threads to not abort on exceptions This solves long outstanding issue: #396. This happens, because some applications or gems do overwrite global setting of `Thread.abort_on_exception=` which is by default set to `false`. This leads to application process to exit and making the spring unable to recover from that. * Use rescue blocks instead of `abort_on_exception=` * Rescue PTY * Use `Spring.failsafe_thread` * Add CHANGELOG
For us spring freezes during the second preload if an app is whining about already existing constant. I assume this is somehow connected with writing to an STDERR with a stale descriptor, but I'm not sure. This is on 1.7.2. |
Okay, I've played with it a little and here's what I found. I don't know enough about why pty was introduced in the first place, however, as a workaround, I'm going to redirect Hope that made any sense. |
markiz@5f3ab73 (in my https://github.com/markiz/spring fork) this is what fixes freezes for us, sorry that I can't wrap it in a nice PR with tests and stuff for now. |
@markiz In my limited testing that also solves a fairly reproducible hang for me as well. |
@markiz that solved it for me as well (Spring would also spike CPU usage to 100%); thanks! |
Can confirm I'm having this issue on Rails 5.2. Getting a bit tiring having to kill the Rails process every so often. Thought I was going mad until I found this issue. |
|
Try Zeus instead - https://github.com/burke/zeus |
|
I had spring hang regularly, sometimes every five minutes. I've manually applied the patch in markiz@5f3ab73 and haven't seen any hangs since. As per #396 (comment) I'm going to submit that patch as a PR. Conveniently, it's also on a branch. |
I'm still seeing this problem with the new spring release 2.1.1. |
My issue came from a file located at I don't know how it got there. I checked my command history and I never ran |
Not to pile on, but this is definitely reproducible with a minimal rails application.
Tested this with Ruby 3.0.0 but have seen the same behavior for a long time with other ruby versions. I tried with the #693 fork changes and it didn't seem to fix this particular issue. I did find something just now that might be interesting/relevant: this error only happens when I'm inside tmux. I wonder how many other people in this thread are using tmux? I typically have no other problems with tmux and tmux itself isn't hung up; even when it hangs I can create a new buffer & then issue Edit: I've also tried updating the listen gem and have seen mixed results Edit 2: I've tested a modified version of my commands above inside of tmux; newest stable ruby + rails + manually activate & install spring + manually start spring. The patch noted at the bottom of this thread in #623 appears to fix it. Spring no longer hangs in tmux; it raises the correct/expected "key not found" error message |
Maybe this will help someone: while in the beginning I thought that |
Worked. Thank you 👍 |
Interesting. I too am on tmux and experiencing this after recently bumping to Ruby 2.6.8. |
I tested this fix (saw that github shows "May be fixed by 623") Inside of tmux I still see the same issue. It still may fix this issue (not sure if my issue is the same as reported by OP) I tried my snippet posted earlier with the latest versions of things:
Not sure which versions I used originally, but since now I'm also seeing it hang outside of tmux as well I wish I'd documented the versions so I could compare. I'm happy to pair on this if anyone wants to, but I'm not even sure where to start with this. My tmux config is available online (as is most of my setup/shell) |
Kind of related, and kind of good news: Spring is not default anymore rails/rails#42997 |
I am having the same issue where Ctrl+c won't work and I have to kill it from task manager by force.
The worst part is that it is random so you don't know when it will happen and once it does from that point on its 100% of the time until you do one of the followings below:
|
Experienced similar hanging with every "rails"-command on Rails 6.1.5 and after trying all kind of sorcery and witchcraft I ended up regenerating binstubs with "rake app:update:bin". This solved all "rails"-command issues for me. |
Wow, 7 years later, finally fixed! 🎉 |
I noticed recently that sometimes Spring hangs if you try to run a test (Minitest) with the wrong filename, for example, a test file that doesn't exist. |
* Configure all threads to not abort on exceptions This solves long outstanding issue: rails/spring#396. This happens, because some applications or gems do overwrite global setting of `Thread.abort_on_exception=` which is by default set to `false`. This leads to application process to exit and making the spring unable to recover from that. * Use rescue blocks instead of `abort_on_exception=` * Rescue PTY * Use `Spring.failsafe_thread` * Add CHANGELOG
Sometimes the PTY slave can be closed, causing an unhandled exception in the thread which is calling `master.read` (socket closed). This change kills the thread before this happens. Related to rails/spring#396 (since this exception was causing Spring to hang)
* Configure all threads to not abort on exceptions This solves long outstanding issue: rails/spring#396. This happens, because some applications or gems do overwrite global setting of `Thread.abort_on_exception=` which is by default set to `false`. This leads to application process to exit and making the spring unable to recover from that. * Use rescue blocks instead of `abort_on_exception=` * Rescue PTY * Use `Spring.failsafe_thread` * Add CHANGELOG
Sometimes the PTY slave can be closed, causing an unhandled exception in the thread which is calling `master.read` (socket closed). This change kills the thread before this happens. Related to rails/spring#396 (since this exception was causing Spring to hang)
We've been having a lot of problems with spring hanging on our systems. I started outputting to a log and here's what I see:
I haven't got a strong idea of what is causing it just yet, though it seems to come up if we change git branches and the like, so maybe some sort of file changes are causing it to just lock up. We have to run
spring stop
and start over.The text was updated successfully, but these errors were encountered: