How to debug backend plugin

Trying to debug the backend plugin (the sample debug adapter plugin generated using yeoman generator)…
Added the following in launch.json:

        {
            "type": "node",
            "request": "attach",
            "name": "Attach to Plugin Host",
            "port": 9339,
            "timeout": 100000,
            "stopOnEntry": true,
            "smartStep": true,
            "sourceMaps": true,
            "internalConsoleOptions": "openOnSessionStart",
            "outFiles": [
              "${workspaceRoot}/debug-adapter/lib/*.js"
            ]
        }

        {
            "type": "node",
            "request": "launch",
            "name": "Launch Browser Backend",
            "program": "${workspaceRoot}/browser-app/src-gen/backend/main.js",
            "cwd": "${workspaceRoot}/browser-app",
            "args": [
              "--hostname=0.0.0.0",
              "--port=3000",
              "--no-cluster",
              "--app-project-path=${workspaceRoot}/browser-app",
              "--plugins=local-dir:plugins",
              "--hosted-plugin-inspect=9339"
            ],
            "env": {
              "NODE_ENV": "development",
              "THEIA_WEBVIEW_EXTERNAL_ENDPOINT": "${env:THEIA_WEBVIEW_EXTERNAL_ENDPOINT}"
            },
            "sourceMaps": true,
            "outFiles": [
              "${workspaceRoot}/browser-app/src-gen/backend/*.js",
              "${workspaceRoot}/browser-app/lib/**/*.js",
              "${workspaceRoot}/**/lib/**/*.js"
            ],
            "smartStep": true,
            "internalConsoleOptions": "openOnSessionStart",
            "outputCapture": "std"
          },

I launched backend debugging (“Launch Browser Backend”) first and then followed by “Attach to Plugin Host”.
I got this error :
Debugging with inspector protocol because Node.js version could not be determined (Error: connect ECONNREFUSED 127.0.0.1:9339)

[original thread by rs]

The plugin host process is created only when there is a frontend, you should make sure that you have the window opened.

“${workspaceRoot}/debug-adapter/lib/*.js”

debug-adapater is it VS Code extension?

[rs]

Thank you, @anton-kosyakov for asking… I created the debug adapter using the instructions here : https://che.eclipse.org/how-to-add-support-for-a-new-debugger-for-che-theia-f459ea806ff

[rs]

Hi @anton-kosyakov , here are the steps that i performed: 1. Started “Launch Browser Backend” in debug view 2. Open http://localhost:3000 in a browser to view the theia ide & 3.Started “Attach to Plugin Host” in debug view. The following error was shown : Debugging with inspector protocol because Node.js version could not be determined (Error: connect ECONNREFUSED 127.0.0.1:9339

[rs]

Hi @anton-kosyakov , as i’m creating theia based custom editor, do you believe that i probably might not have included the extensions that are needed for this ?

Attach to Plugin Host even if it works it will debug the plugin host process, not the process of debug adapter.

I’m not sure why you get ECONNREFUSED, it should work.