Introduction

This repo reproduces an issue of the debug gem as described below.

Issue Description

Breakpoints added via VS Code seems to be lost after Rails' code reload.

Steps

  1. Clone this repo.

  2. Run $ bundle install.

  3. Run $ bundle exec bin/rails db:migrate RAILS_ENV=development.

  4. Run $ bundle exec rdbg -O -n -c -- bundle exec bin/rails s to run the server with debugger in server mode.

  5. Press F5 to attach VS Code to the debugger.

  6. Go to app/controllers/posts_controller.rb and place an VS Code breakpoint at line 6.

    def index
      @posts = Post.all # set the breakpoint at this line
    end
  7. Verify the breakpoint can be hit:

    1. In browser, visit http://localhost:3000.
    2. See the breakpoint being hit.
    3. Press F5 again to continue the program.
  8. Add puts "foo" at app/controllers/posts_controller.rb:6

    def index
      puts "foo"
      @posts = Post.all
    end
  9. Refresh the page in browser.

Expected Behaviour

The breakpoint should still be hit.

Actual Behaviour

The breakpoint would be ignored.

Other Notes

From DAP server logs, it looks like the debugger does receive updated setBreakpoints request:

#25986:[>] {"command":"setBreakpoints","arguments":{"source":{"path":"/Users/hung-wulo/src/github.com/st0012/debug-issue/app/controllers/posts_controller.rb","name":"posts_controller.rb","sourceReference":0},"lines":[6],"breakpoints":[{"line":6}],"sourceModified":true},"type":"request","seq":13}
#25986:[<] {"type":"response","command":"setBreakpoints","request_seq":13,"success":true,"message":"Success","body":{"breakpoints":[{"verified":true}]},"seq":977}

But the breakpoint wasn't actually added.