0x2c7/ruby_jard

[BUG] Slows the the Rails server to a crawl after first use (30+ seconds page loads)

feliperaul opened this issue · 6 comments

Describe the bug

First of all, this gem is awesome. However, I can only use it once, forcing me to restart the rails server afterwards.

The bug manifests itself like this: I use jard anywhere in my code, inspect what I wanted to expect, and then I type exit on it's console to finish execution. I then proceed to remove the jard line and go back to normal life.

However, Rails thens takes an unreasonable time to render the next page... what was a 500ms load in development becomes a Completed 200 OK in 27468ms (27 seconds) after using jard.

What is even weirder is that Chrome keeps spinning even after rails console stated that it had completed the request. It takes one extra minute to display the page in the browser.

To solve it, I need to restart my rails server.

Environment (please complete the following information):

  • OS: MacOs Catalina 10.15.6
  • iTerm2 (tested with and without Overmind)
  • Output when you run tput colors in your terminal: 256
  • Output when you run echo $TERM in your terminal: xterm-256color
  • Output when you run stty:
    speed 38400 baud;
    lflags: echoe echok echoke echoctl pendin
    iflags: iutf8
    oflags: -oxtabs
    cflags: cs8 -parenb
  • Do you use tmux/screen or similar tty multiplexer?: I use Overmind, but I tested with a vanilla rails s in a new tab and it happens just the same

An update: while the Chrome tab keeps on spinning, I got this error message:

image

Another update: I can confirm that with binding.pry everything is working as expected.

0x2c7 commented

Hi @feliperaul, let me confirm:

  • The slowness happens when you inject jard, refresh the page on chrome, inspect, type exit, remove jard. Then, the next page is unacceptably slow right?
  • Or, you inject jard, inspect, then continue and the page load is slow?

The message is interesting. That event should only be raised then the terminal emulator is resized.. Does it popup when you are in Overmind, or in a vanilla terminal emulator?

Hi @nguyenquangminh0711

First option: The slowness happens when I inject jard, refresh the page on chrome, inspect, type exit, remove jard. Then, the next page is unacceptably slow.

About the message, I'm not in front of the computer right now, but if I recall correctly, it was a vanilla Rails terminal.

What happens is, with iTerm2, I use CMD SHIFT ENTER all the time to resize the terminal windows to occupy fullscreen. I probably did that with jard even on the vanilla rails terminal, because when jard is activated only half the screen is too small for it.

Let me know if I can help debugging any further!

0x2c7 commented

Thank you. I think that's enough for me to debug. At the first glance, I think there are some conflicts between rails autoreload so that tons of scripts are running forever. During that time, when you resize, a race condition happens and pop that error out. I never go into this scenario before. Gonna test it out and let you know if I found some clues 😉

0x2c7 commented

Hi @feliperaul, I tested on my local, and I can confirm that it's truly a bug. The slowness is significant. I implemented a fix, and the situation is good (for me). Could you test it again by pointing jard to my branch?

gem 'ruby_jard', git: 'https://github.com/nguyenquangminh0711/ruby_jard', ref: 'bug/fix-slowness-after-exit'