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

Do not kill the Ruby process when IDE debugger session disconnects #199

Open
TSMMark opened this issue Sep 15, 2020 · 5 comments · May be fixed by #200
Open

Do not kill the Ruby process when IDE debugger session disconnects #199

TSMMark opened this issue Sep 15, 2020 · 5 comments · May be fixed by #200

Comments

@TSMMark
Copy link

TSMMark commented Sep 15, 2020

When my IDE disconnects from the debug session, it kills the main process – the process started by rdebug-ide command. How to avoid this?

If this is not supported already, I would be happy to try to implement a CLI flag for this if given a pointer or two in the right direction.

I scoured this repo for a way to do this or an open issue but couldn't find anything. --disable-int-handler sounded like it might do it, but has no effect. Sorry if this is a duplicate issue!

@lalunamel
Copy link

I'd like this feature as well.

I'm not a maintainer or anything, but I've been noodling around the code recently and can point you in the right direction.

Here's the bit of code that handles the quit command, which is sent when your IDE disconnects from a debugging session. https://github.com/ruby-debug/ruby-debug-ide/blob/master/lib/ruby-debug-ide/commands/control.rb#L2

Commands are sent over a socket from the IDE to ruby-debug-ide and parsed here. https://github.com/ruby-debug/ruby-debug-ide/blob/master/lib/ruby-debug-ide/ide_processor.rb#L75

I'd imagine any solution to prevent ruby-debug-ide from terminating would involve mucking around in control.rb

@hurricup
Copy link
Contributor

@TSMMark what version of the gem used?

@TSMMark
Copy link
Author

TSMMark commented Sep 17, 2020

@hurricup latest. ruby-debug-ide (0.7.2)

@TSMMark
Copy link
Author

TSMMark commented Sep 25, 2020

In my quick local testing, it looks like simply removing the exit! line here works like a charm!

exit! # exit -> exit!: No graceful way to stop threads...

The same Ruby process can later be reattached to the debugger and everything.


I'll try to submit a PR asap that optionally skips the exit! based on cli flag or env var or something

@TSMMark TSMMark linked a pull request Sep 25, 2020 that will close this issue
@yasaichi
Copy link

yasaichi commented Sep 10, 2022

For the future googlers, here's my patch until the PR is merged:

$ cat bin/rdebug-ide
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
require "ruby-debug-ide"

Debugger::QuitCommand.prepend(
  Module.new {
    def execute
      # NOTE: We must ensure that all breakpoints are cleared before disconnecting sessions,
      # or you'll face a `closed stream` error.
      Debugger.breakpoints.clear
      @printer.print_msg("finished")
    end
  }
)

load Gem.bin_path("ruby-debug-ide", "rdebug-ide")

Usage:

$ bin/rdebug-ide [same arguments as the original ones]

instructure-gerrit pushed a commit to instructure/canvas-lms that referenced this issue Nov 7, 2022
See https://instructure.atlassian.net/l/cp/nefWMv5k for debugging setup.
RubyGems version of rdebug-ide has a bug (behavior?) where it will
terminate the debugged process when you disconnect it. Credit to
ruby-debug/ruby-debug-ide#199 (comment)
for the workaround.

flag=none
test plan
- set up VS Code IDE debugging per instructions in the Confluence link
  above
- start debugging
- detach your debugger
* Web container should still be running and Canvas should still work

Change-Id: Ifc7c6376dde2a4f23d709f9d32076fc45a0e1483
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/302228
Tested-by: Service Cloud Jenkins <[email protected]>
Reviewed-by: Jake Oeding <[email protected]>
QA-Review: Jon Scheiding <[email protected]>
Product-Review: Jon Scheiding <[email protected]>
Build-Review: Aaron Ogata <[email protected]>
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

Successfully merging a pull request may close this issue.

4 participants