Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging extension with VSCode #29

Open
Danp2 opened this issue Feb 27, 2023 · 10 comments
Open

Debugging extension with VSCode #29

Danp2 opened this issue Feb 27, 2023 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@Danp2
Copy link

Danp2 commented Feb 27, 2023

P.S. I wanted to investigate this myself, but all my breakpoints appeared as unbound. Can you provide guidance on this?

Are you running the code using the "Client + Server" option from the drop-down list in the debug tab?

Originally posted by @genius257 in #27 (comment)

@Danp2
Copy link
Author

Danp2 commented Feb 27, 2023

@genius257 When I use the Client + Server option, the task runs, but it appears to just "spin" like it's watching or waiting for something else to occur. What other actions should I perform? Is there a particular order that these steps should occur in?

@Danp2
Copy link
Author

Danp2 commented Feb 27, 2023

This is what I see in the terminal --

 *  Executing task: npm run watch 


> [email protected] watch
> webpack --watch

asset main.js 581 KiB [compared for emit] [big] (name: main) 1 related asset
runtime modules 670 bytes 3 modules
modules by path ./node_modules/ 550 KiB
  modules by path ./node_modules/vscode-languageclient/ 259 KiB
    modules by path ./node_modules/vscode-languageclient/lib/common/*.js 250 KiB 25 modules
    modules by path ./node_modules/vscode-languageclient/lib/common/utils/*.js 7.21 KiB 3 modules
    + 2 modules
  modules by path ./node_modules/vscode-languageserver-protocol/ 79.5 KiB
    modules by path ./node_modules/vscode-languageserver-protocol/lib/common/*.js 76 KiB 19 modules
    + 3 modules
  modules by path ./node_modules/vscode-jsonrpc/ 113 KiB 16 modules
  + 5 modules
./src/main.ts 2.18 KiB [built] [code generated]
external "vscode" 42 bytes [built] [code generated]
../node_modules/path-browserify/index.js 15.8 KiB [built] [code generated]
webpack 5.75.0 compiled successfully in 4382 ms

asset main.js 949 KiB [compared for emit] [big] (name: main) 1 related asset
runtime modules 670 bytes 3 modules
modules by path ./node_modules/ 334 KiB
  modules by path ./node_modules/vscode-languageserver-protocol/ 79.5 KiB 22 modules
  modules by path ./node_modules/vscode-jsonrpc/ 113 KiB 16 modules
  modules by path ./node_modules/vscode-languageserver/ 66.1 KiB 15 modules
  + 2 modules
modules by path ./src/ 200 KiB
  ./src/main.ts 18.5 KiB [built] [code generated]
  ./src/autoit/internal.ts 137 KiB [built] [code generated]
  ./src/autoit/Parser.ts 7.97 KiB [built] [code generated]
  + 2 modules
modules by path ../node_modules/ 403 KiB
  ../node_modules/vscode-uri/lib/esm/index.js 11.8 KiB [built] [code generated]
  ../node_modules/autoit3-pegjs/index.js 168 bytes [built] [code generated]
  ../node_modules/autoit3-pegjs/out/autoit3.js 391 KiB [built] [code generated]
webpack 5.75.0 compiled successfully in 4170 ms

and it never proceeds beyond this point. If I press Ctrl+C, it asks if I want to exit the batch file. I answered No, and then it proceeded to load the separate instance of VSCode with the extension running.

Could this be caused by an outdated library, Node, etc?

@Danp2
Copy link
Author

Danp2 commented Feb 27, 2023

Seems like preLaunchTask script never finishes when the client is launched.

@Danp2
Copy link
Author

Danp2 commented Feb 27, 2023

Make some headway by installing this extension and then adding the following to tasks.json --

        {
            "type": "npm",
            "script": "build",
            "group": "build",
            "problemMatcher": ["$ts-webpack", "$tslint-webpack"]
        },
        {
            "type": "npm",
            "script": "watch",
            "group": "build",
            "isBackground": true,
            "problemMatcher": ["$ts-webpack-watch", "$tslint-webpack-watch"]
        }

Now the client launches successfully, but I'm not sure if the server attach is working (all breakpoints still appear as unbound).

@genius257
Copy link
Owner

I'll be honest, i haven't tried the "Client + Server" option before, due to a "interesting" node setup on my main machine that runs windows 7.
But this makes sense to get working, for debugging tricky problems that will raise as the complexity grows.
I will setup a proper development environment for this on my secondary machine (windows10) and see if i can get breakpoints to work.
Here is the extension sample i based my initial setup on: https://github.com/microsoft/vscode-extension-samples/tree/main/lsp-web-extension-sample
I do not expect to solve this today, but either a solution or an explanation will be found! 😄

@genius257
Copy link
Owner

A small update: missing configuration from the .vscode/tasks.json seemed to be the issue for the npm watch task seemingly being stuck.

I'm still not at testing with breakpoints yet, but I will let you know when i progress more! 😄

@genius257
Copy link
Owner

So based on this i can see the attach to server config expect the port to be 6009.
But the server never gets that information when created here.
It also seems the server does not support this when running as a web-worker 😞

The only way I've found for getting working breakpoints on the server code so far, is to Toggle Developer Tools (Ctrl+Shift+I) on the Extension development Host window and either find your wanted code in the bundle file and select it, or use the debugger statement in code.
For finding the bundled scripts in the developer tools, Choose the Sources tab and:

  • I found the client under (main.js ➡️ serverExportVar ➡️ src ➡️ main.ts)
  • I found the server under (vscode-app ➡️ FullPathToServerDistFolder ➡️ main.js)

It is very disappointing and surprising to me that the combination of poor example quality they provide, combined with this problematic debuggability.

@Danp2
Copy link
Author

Danp2 commented Apr 1, 2023

This issue appears related --

microsoft/vscode-extension-samples#836

@genius257
Copy link
Owner

Very nice! 😄
There seems to currently be sone issues with the best solution, so I'll keep an eye on the related issues and implement the fix, when the first fix no longer causes a crash in certain circumstances 😅

@genius257 genius257 added the bug Something isn't working label Jan 24, 2024
@genius257
Copy link
Owner

genius257 commented Feb 9, 2024

So the relevant vscode issue was finally "resolved".
I have updated files, to try and make it work, but have not been able to verify if it works.

My issue is that I'm using a development container for my node runtime and debugging extension from a devcontainer seems to be broken and i cannot find much information about it so far.

I have not abandoned hope, and will revisit this issue at a later date (repeatedly if i haft to), but for now i will focus on getting the extension usable and stable.

Sorry for the long wait for the disappointing update 😞

@genius257 genius257 self-assigned this Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

2 participants