ruby / vscode-rdbg

VSCode Ruby rdbg Debugger
MIT License
176 stars 50 forks source link

Having multiple debugging sessions at once #434

Open sbungartz opened 7 months ago

sbungartz commented 7 months ago

Hi, thanks for working on debugging integration for ruby in VS Code! I've just started out trying to figure out how to get this into our project and so far I can launch the rails server with bin/rails s and then I get its output in a Debug Console and I can use breakpoints and its great. I can also run an rspec test from under the cursor (although you have to remember to switch to the correct configuration before hitting F5, but that's fine). The output is also displayed in a Debug Console with the matching name of the different launch configuration.

But:

When I have the Rails server running and then want to run a test multiple strange things happen – some of which might be VS Code issues and not specific to this plugin, but I will list all my findings since I'm not sure.

  1. I cannot hit F5 to start the test but instead I have to klick the green arrow next to the configuration dropdown (I think this might be because VS Code sees there is already something running and therfore ignores this)
  2. The tests are started but the output is shown in the Debug Console of the Rails process alongside some error messages that indicate that something might be going wrong: image
  3. I can now set breakpoints in the test and they are triggered but the weirdness continues: When inside the "Rails Server" console the debugging tools also seem to switch to that context and do not show any info about the breakpoint and hovering variables does not work – but the repl works in the context of the spec. Conversely when switching to the RSpec console the UI elements match the debugging state of the test but the repl does not know the variables and methods from that context (unsurprisingly)
  4. Edit as I only noticed this after submitting: The Rails server does still run in the meantime and new logs from it (when loading a page) show up in the RSpec Debug Console. After finishing the RSpec test new logs from the server show up in the "Rails Server" console again 🤯

Do you have any idea how this might happen?

These are the two launch configurations involved:

(second edit: The same also happens when I remove the "internalConsoleOptions": "openOnSessionStart" option)

  "configurations": [
    {
      "cwd": "${workspaceRoot}",
      "name": "Rails Server",
      "presentation": {
        "group": "Rails",
        "order": 1
      },
      "type": "rdbg",
      "request": "launch",
      "script": "${workspaceRoot}/bin/rails s",
      "preLaunchTask": "Rails Dependency Tasks",
      "internalConsoleOptions": "openOnSessionStart",
      "env": {
        "GOOD_JOB_EXECUTION_MODE": "external"
      }
    },
    {
      "cwd": "${workspaceRoot}",
      "name": "RSpec Tests - Run at cursor position",
      "presentation": {
        "group": "RSpec",
        "order": 1
      },
      "internalConsoleOptions": "openOnSessionStart",
      "type": "rdbg",
      "request": "launch",
      "script": "${workspaceRoot}/bin/rspec",
      "args": [
        "${file}:${lineNumber}"
      ]
    }
  ]

Thanks in advance for your efforts working on this! Let me know if you need any more information.