microsoft / vscode-mock-debug

Starter sample for developing debug adapters for VSCode.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The build/run instructions are incomplete and flawed.

billw2012 opened this issue · comments

I had to run yarn manually (after installing it), and the default runMode is set to external which doesn't allow you to debug the adapter when you press F5.
It should be setup for debugging not testing by default, but even if not, it should at least explicitly say the runMode needs to be changed so that debugging will work.
People writing debug adapters for VSCode aren't going to be javascript or node.js experts (or even novices) on a lot of cases, they are just trying to get their language/whatever to work.
The examples and instructions should reflect that.

@billw2012 I just tried debugging the extension per the readme in the project itself and have not had luck. Looking at package.json I cannot figure out which of the scripts I should run.

Care to share what you did to get this working? By this I mean achieving what the second part of the readme claims, which is debugging the debug adapter itself in another instance of VS Code?

Thanks in advance!

To anyone reading this:

  1. Have yarn installed on your system
  2. Run yarn install
  3. Choose "Extension" debug config in the "normal" VS Code instance and run/debug that
  4. The rest of the instructions are correct, just add readme.md and run F5 to debug it

Actually, I don't know what to do in order to get to debug the debug adapter itself. Tried several run configurations, nothing seems to work.

Finally figured it out...

So, the key is the hint from @billw2012 (thanks!) about runMode - this is in the source of the debug adapter, in the mockRuntime.ts. Setting the default value to inline works for me, external did not work.

Huh, okay I didn't try inline, I assumed that this would not work as I assumed it instantiates the adapter in the debug target.

it instantiates the adapter in the debug target.

@billw2012 What did you try? What worked for you?

Using runMode server and Extension debug config seemed to work,

I think current steps to run from scratch would be then:

  1. Clone the repo
  2. Install yarn
  3. Run yarn in root
  4. Change runMode in mockRuntime.ts to "inline" (or possibly "server")
  5. Make sure Extension debug config is selected and press F5

runMode doesn't even exist anymore in mockRuntime.ts and so the build & run steps fail completely.

When running yarn install from repo root, it gives one warning;
warning mock-debug@0.46.7: The engine "vscode" appears to be invalid.

When hitting F5 from the repo root;

yarn run v1.22.17
warning mock-debug@0.46.7: The engine "vscode" appears to be invalid.
$ webpack --watch --devtool nosources-source-map --info-verbosity verbose --config ./build/extension.webpack.config.js
[webpack-cli] Error: Unknown option '--info-verbosity'
[webpack-cli] Run 'webpack --help' to see available commands and options
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

So what's next? It doesn't even seem to build properly.

Edit: I think it was because I had vscode open when I tried doing yarn that made it fail. Closing vscode, do yarn, open vscode, and follow the steps worked for me.

@billw2012 you can ignore the warning: "The engine "vscode" appears to be invalid."

You don't have to close VS Code while running yarn.
If you just use "F5" VS Code will build the extension and launch it for debugging.

And I've fixed the broken "tsl-problem-matcher" extension recommendation.

Hi,

I tried to follow @billw2012 instructions and I still end up with:
image

any idea ?

@jdeantoni are you on Windows?

No, i’m on open suse. An error message also tell me cannot connect to localhost:aNumber… I can give you the exact message if needed

But you are using the standard VS Code?

Yes, I do. I'm using this version of vscode:
image

also here is the exact stack frame I have:

[2021-11-10 19:37:38.935] [renderer1] [error] [Extension Host] Error: Could not connect to debug target at http://localhost:53556: Could not find any debuggable target at Object.retryGetNodeEndpoint (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1396584) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async f.launchProgram (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1412163) at async f.launch (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1436173) at async t.Binder.captureLaunch (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1227825) at async t.Binder._launch (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1227370) at async Promise.all (index 1) at async t.Binder._boot (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1226422) at async t.default._onMessage (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1319096) [2021-11-10 19:37:38.962] [renderer1] [error] Error processing attach: Error: Could not connect to debug target at http://localhost:53556: Could not find any debuggable target at Object.retryGetNodeEndpoint (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1396584) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async f.launchProgram (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1412163) at async f.launch (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1436173) at async t.Binder.captureLaunch (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1227825) at async t.Binder._launch (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1227370) at async Promise.all (index 1) at async t.Binder._boot (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1226422) at async t.default._onMessage (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1319096): Error: Error processing attach: Error: Could not connect to debug target at http://localhost:53556: Could not find any debuggable target at Object.retryGetNodeEndpoint (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1396584) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async f.launchProgram (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1412163) at async f.launch (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1436173) at async t.Binder.captureLaunch (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1227825) at async t.Binder._launch (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1227370) at async Promise.all (index 1) at async t.Binder._boot (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1226422) at async t.default._onMessage (/usr/share/code/resources/app/extensions/ms-vscode.js-debug/src/extension.js:2:1319096) at o.handleErrorResponse (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:1024:33974) at vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:1024:33280 at async o.launchOrAttach (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:1024:26037) at async N.launchOrAttach (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:1906:12304) at async J.launchOrAttachToSession (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:1906:43188)

EDIT: I have the same behaviour if I update to vscode 1.62.0
EDIT2: it works correctly on another machine with a very similar setup:
image

@jdeantoni I cannot reproduce the problem.
Here is what I did on Ubuntu 21.10 LTE:

  • in a new directory git clone https://github.com/microsoft/vscode-mock-debug.git
  • opened new folder vscode-mock-debug in VS Code 1.61.2
  • VS Code asked whether to install the recommended extensions: I answered "yes"
  • I opened new Terminal in VS Code and ran yarn
  • switched to VS Code's "Run and Debug" viewlet
  • selected launch configuration "Extension" in the debug drop down menu and then pressed the "play" button

A new window appeared where I selected the "readme.md" file and then selected "Debug" from the editor's "Run and Debug" menu.
-> Mock debug stopped on the first line

@weinand , thanks for the help. I have the problem only one of my machines :-/ On the others it works like for you.
I'll check if the problem comes from another extension or perhaps the firewall or so and I'll get back to you.
If you have any idea on what to check first, do not hesitate to tell me.

The firewall might be the culprit because in your stack trace I see a

Error: Could not connect to debug target at http://localhost:53556: Could not find any debuggable target at Object.retryGetNodeEndpoint