vscode-rdbg icon indicating copy to clipboard operation
vscode-rdbg copied to clipboard

serverReadyAction doesn't work when output is sent to the debug console (ie useTerminal is false)

Open rockorequin opened this issue 2 years ago • 5 comments

In version 0.1.0, output is sent by default to the debug console (it used to only go to a new terminal, but now you can choose where it goes via the useTerminal setting).

I'm running a Rails server and the serverReadyAction doesn't execute when output goes to the debug console. However, if I specify "useTerminal": true in launch.json, serverReadyAction works, ie the webpage http://localhost:3000 opens in a browser window.

My launch.json configuration is:

      "name": "rdbg",
      "type": "rdbg",
      "request": "launch",
      "script": "${workspaceRoot}/bin/rails",
      "cwd": "${workspaceRoot}",
      "args": [
        "server"
      ],
      "serverReadyAction": {
        "pattern": "Listening on http://127.0.0.1:([0-9]+)",
        "uriFormat": "http://localhost:%s",
        "action": "openExternally"
      }

rockorequin avatar Feb 01 '23 04:02 rockorequin

what is "serverReadyAction"?

ko1 avatar Feb 08 '23 04:02 ko1

serverReadyAction instructs VSCode to scan the log for a pattern and then take an action once it's seen (openExternally tells it to open the uriFormat string in a browser). See https://code.visualstudio.com/docs/editor/debugging#_automatically-open-a-uri-when-debugging-a-server-program.

rockorequin avatar Feb 08 '23 06:02 rockorequin

Thank you for the information. This is first time to see.

Do you know other debuggers (on other languages) support it on the debug console?

ko1 avatar Mar 07 '23 16:03 ko1

Excellent question! I'm not sure about other languages, but serverReadyAction works with output going to the debug console in the "Ruby" extension by Peng Lv (I think it's this one: https://marketplace.visualstudio.com/items?itemName=rebornix.Ruby). It uses the ruby-debug-ide and debase gems.

I just ran it to confirm that a new browser window opens once the Rails server writes "* Listening on http://127.0.0.1:3000" to the debug console. My launch.json contains:

    {
      "name": "rdebug-ide",
      "type": "Ruby",
      "request": "launch",
      "program": "${workspaceRoot}/bin/rails",
      "cwd": "${workspaceRoot}",
      "args": [
        "server"
      ],
      "serverReadyAction": {
        "pattern": "listening on http://127.0.0.1:([0-9]+)",
        "uriFormat": "http://localhost:%s",
        "action": "openExternally"
      }
    },

rockorequin avatar Mar 08 '23 01:03 rockorequin

Thank you so there is a way to support it on the debug console...

ko1 avatar Mar 08 '23 14:03 ko1