Phlex triggers existing bug between puma and ruby/debug
This is an existing bug between ruby/debug and puma: https://github.com/ruby/debug/issues/1121 in ruby/debug and https://github.com/puma/puma/issues/3627
I've discovered that simply adding Phlex to a minimal rails project triggers this, so the "out of the box" debugging experience for rails breaks.
Steps to reproduce
-
rails new debugtest --skip-jbuilder --skip-test -j esbuild -c tailwind - Add a route to routes.rb:
get "home" => "home#index" - Add Home controller with index method:
class HomeController < ApplicationController
def index
debugger
render plain: "Hello, world!"
end
end
- run
bin/dev, point browser at localhost/home, everything works as expected;p selfin attached debugger works fine, server continues after ctrl-d in debugger and breakpoints can be triggered again.
Add phlex:
-
bundle add phlex phlex-rails -
bundle exec rails generate phlex:install
Restart the dev server, navigate to the home page again, attach the debugger, and try p self
Now we get an error message from the debugger:
# No sourcefile available for /home/path/to/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/puma-7.0.4/lib/puma/single.rb
=>#0 [C] Thread#join at ~/.asdf/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/puma-7.0.4/lib/puma/single.rb:66
#1 Puma::Single#run at ~/.asdf/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/puma-7.0.4/lib/puma/single.rb:66
# and 20 frames (use `bt' command for all frames)
Stop by SIGURG
A subsequent p self will work, but the dev puma server will now be hung, serving no more requests and will need a kill -9 before it exits
Simply installing Phlex into a minimal rails codebase triggers this existing bug between puma and ruby/debug.
Ruby v 3.4.5, Rails v 8.0.2, Puma v 7.0.4, debug v 1.11.0, phlex v 2.3.1
One more note, This reproduces both on OSX and in WSL2 ubuntu under windows.
Thanks for the detailed report. This is likely related to Phlex::Kit. I wonder if removing the extend Phlex::Kit stops this from happening.
@joeldrapper - hey, checking in on this. Have you had any time/energy to investigate? I've been working on a project that's getting close to being open-sourced, and I'd love it if the "standard" debug worked with it, and it's using Phlex.
@joeldrapper - hey, checking in on this. Have you had any time/energy to investigate? I've been working on a project that's getting close to being open-sourced, and I'd love it if the "standard" debug worked with it, and it's using Phlex.
Sorry I didn’t have more time to look at this sooner. It appears to be working fine for me on the latest everything — Ruby, Rails, Puma, Debug, Phlex. Not sure which one fixed it.
I’m going to close this but if let me know if you have any ongoing problems and I’ll try to do some more debugging.