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

server debug broken on the lsp-sample #836

Closed
Tracked by #922
mateusabelli opened this issue Mar 18, 2023 · 10 comments
Closed
Tracked by #922

server debug broken on the lsp-sample #836

mateusabelli opened this issue Mar 18, 2023 · 10 comments
Assignees

Comments

@mateusabelli
Copy link

mateusabelli commented Mar 18, 2023

The problem

Referred project

According to the docs It should've been possible to debug both client and server, but there is no Attach to Server configuration in the .vscode/launch.json anymore and I could not find any other methods or documentation to make my server breakpoints hit when trying to debug.

Steps to reproduce

  • clone the repo
  • cd into the lsp-sample
  • run npm install and npm run compile
  • add breakpoints to client/src/extension.ts
  • add breakpoints to server/src/server.ts
  • open your debug panel choose Launch Client

server breakpoints are gray, showing "unbound breakpoint"

Initial thoughts

After running into this issue the first thing I noticed was the missing Attach to Server configuration, so I went to this repository and looked through the previous commits and found the following.

  • The configuration is present and everything worked as expected at this commit e1ecdae
  • After this patch, debugging the server did not worked anymore dbee9a0

Possible solution

If nothing else breaks, we could maybe revert some of the configurations to that previous working state?

lsp-sample/.vscode/launch.json
dbee9a0#diff-767cc09063399b4f3bc13098f37ad284f1e1a4333cf28740ca5da00d5d451f23

lsp-sample/client/src/extension.ts
dbee9a0#diff-a6a41ed849771f4fda193238ec10d62e59f5bf1a09029b710852d17389105d3b

@dbaeumer
Copy link
Member

@connor4312 could be please comment. You remove the attach configs in favor of autoAttachChildProcesses but that doesn't work under WSL so I needed to remove it (see microsoft/vscode-js-debug#1503)

We either need to bring the attach configs back or make the autoAttachChildProcesses work?

@connor4312
Copy link
Member

connor4312 commented Mar 21, 2023

It's some kind of native crash, I was hoping the Electron 22 upgrade would fix things, so deferred investigation on it last iteration. (But then we delayed the Electron 22 migration due to other problems.)

Using autoAttachChildProcess is definitely the 'right' (and easiest!) way to debug, I think we should keep it there and get the crash fixed. I would close this issue as a dupe of the one in js-debug.

@gentledepp
Copy link

@TobiasLadner

I have no idea how the autoAttachChildProcess works, so I will explain how I fixed it for my case:

  1. Add the missing launch configuration
		{
			"name": "Attach to Server",
			"type": "node",
			"request": "attach",
			"address": "localhost",
			"port": 6009,
			"sourceMaps": true,
			"outFiles": ["${workspaceRoot}/server/out/**/*.js"],
			"preLaunchTask": {
				"type": "npm",
				"script": "watch"
			}
		},
  1. Run "Launch Client"
  2. once a new VS Code instance opens, run "Attach to server"

Your break points in both client and server should now be hit:

vs_lsp-sample_debug

@VisualDev-FR
Copy link

Impossible for me to hit a breakpoint on the server side, or even to display a console.log...

@hlin-neo4j
Copy link

Impossible for me to hit a breakpoint on the server side, or even to display a console.log...

Found the issue. Along with @gentledepp 's solution, you also need to change extension.ts to look like

export function activate(context: ExtensionContext) {
    const serverModule = context.asAbsolutePath(
        path.join('server', 'out', 'server.js')
    );
    // The debug options for the server
    // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
    let debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };

    const serverOptions: ServerOptions = {
        run: { module: serverModule, transport: TransportKind.ipc },
        debug: {
            module: serverModule,
            transport: TransportKind.ipc,
            options: debugOptions
        }
    };
    
    ....
}

The "Attach to Server" piece in launch.json needs to be paired with these debugOptions, both of which were removed from the git source, and the latter being present in the tutorial. I added this part in and the breakpointing worked for me

@mtiller-jh
Copy link

Even with the changes from @gentledepp and @hlin-neo4j, I could not get breakpoints working. It is really too bad that sample code that is supposed to run out of the box doesn't work. I'm not sure I understand @connor4312's comment that autoAttachChildProcess is the easiest way to debug. Whatever way that is supposed to make things "easy" doesn't seem to be working for me on VS Code 1.85.0 (Darwin am64 22.6.0). Quite frustrating when you can't even get started.

@dbaeumer
Copy link
Member

I updated the dependencies and fixed the server debug problem.

@mtiller-jh
Copy link

Thanks @dbaeumer

However, I think most (if not all) of the other lsp-* projects have this same issue. As far as I can tell, this fix is only applied to one of them. I could be wrong, but it looks that way to a novice like me at least.

@dbaeumer
Copy link
Member

I will update the once that I own as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants
@gentledepp @dbaeumer @connor4312 @mateusabelli @hlin-neo4j @VisualDev-FR @mtiller-jh and others