debug icon indicating copy to clipboard operation
debug copied to clipboard

✨ Add on_client_connected to Session.open, to allow for synchronization

Open marianosimone opened this issue 3 years ago • 0 comments

Description

Add a way for callers to get notified when a client gets connected to the debugger.

This solves Feature request: Stop debugger until first client connects · Issue #739 · ruby/debug.

A caller can now do something like:

client_connected = Concurrent::IVar.new
DEBUGGER__.open(nonstop: true, on_client_connected: -> {client_connected.set(true)})
client_connected.wait()

Additional context

We are working to integrate debug.rb into Stripe's Ruby test runner. The test runner needs to start the server and wait for VS Code to connect before running the tests.

debug/open does not work for this use case, as it pauses the program when the debugger starts, but does not resume the program after VS Code connects. Instead, VS Code reports the program as paused on a breakpoint in our test runner code. The user then has to hit "resume" to run their tests and hit the breakpoints that they actually set.

marianosimone avatar Sep 02 '22 20:09 marianosimone