-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Figure out why EH debugging doesn't work in Live Share #56471
Comments
EH debugging uses a debugger of type "extensionHost", but this debugger is almost identically to the node debugger and has only a few lines of code where its behaviour differs. EH debugging is based on the "attach" setup available for node.js debugging:
Instead of using the "extensionHost" debugger for this, it is possible to use a regular "node" debugger. In this case the launch of the VS Code workspace window and EH process must be done manually and a debug configuration of type "attach" could be used to attach to the EH. The reason why we've introduced a new debug type "extensionHost" is because we want to support some typical EH debugging workflows automatically and we use the debug type as a discriminator. One typical EH debugging workflow is the EH restart which frequently occurs when opening a new project or when the "Reload Window" action is run. When a reload happens VS Code broadcasts a "reattach" event which is picked up by VS Code debugger UI to terminate the debug session with the old EH and attach to a new extension host process (with a different debug port). Here is a minimal debug configuration for EH debugging: {
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}",
]
}, Since VS Code controls the lifecycle of the EH, the node.js process is not directly launched from the debug adapter and hence it is not specified in the launch configuration. Instead we use the VS Code executable itself (available in the variable As arguments only a path to the extension workspace is given but additional arguments are passed behind the scenes from the debug adapter. The debug console shows what gets executed:
The We are passing these arguments behind the scenes because we do not want to leak these implementation details into debug configurations (which avoids data migration issues later). From my perspective I cannot spot anything that might result in a problem in the LiveShare setup. @rodrigovaras do you see anything problematic? |
Thanks Andre for the detailed explanation on how the extension host debugging works. If i understood you correctly should my adapter attempt to launch vscode with the --extensionDevelopmentPath and then at the same time launch the node adapter with something like this: A couple of questions:
|
I think the important thing to understand is that the "node-debug2" DA is registered under two different names: "node" and "extensionHost". "node" is used to launch node.js programs and "extensionHost" is used to launch node.js as an extension host in the context of VS Code. So the launching of the debuggees (either plain node.js or VS Code's node.js) is implemented in the DA "node-debug2". There is no need for you to do anything special (like writing any launching code). The "node-debug2" DA will find a free port and pass this to either node.js or VS Code as the debug port to use. And since the DA knows the debug port it will be able to attach to it for debugging. A small difference is the additional "debugId" argument. The debug ID is a session ID that the VS Code debug UI creates for a debug session. VS Code passes it as an (undocumented) attribute "__sessionId" on the arguments of the DAP "launch" request and the "extensionHost" debug adapter adds it to the arguments passed to vscode debuggee. But LiveShare should not have to deal with this in any way because VS Code passes the sessionID and the DA picks it up. To emphasize how similar node.js and EH debugging are, here are the steps done in the "node-debug2" DA: for debug type "node":
for debug type "extensionHost":
As you can see there is no big difference between regular node.js debugging and extension host debugging (which is the reason why "node" and "extensionHost" share the same implementation). However, from a LiveShare perspective there might be catch: The EH node.js is running in a new VS Code workbench window which is independent from the project in which the debugger is running. For LiveShare this probably means that the new VS Code instance is not automatically shared with other LiveShare parties (but I'm not sure about this). Basically this is the same as opening a new workspace window from a LiveShare shared VS Code project. Is the new project window automatically shared via LiveShare? If not, then the EH window will not be either. |
Can you point me to the code of the DA (node2) that does the launch, etc.. |
The launch code is here: https://github.com/Microsoft/vscode-node-debug2/blob/ed7e076778a09e1445e7e883e6f20369f7759a71/src/nodeDebugAdapter.ts#L231-L262 The "liveShare" DA is basically a transparent proxy for any DA including the "extensionHost" DA. Any additional argument passed from the user's launch configuration via the DAP "launch" request to the final DA must be tunnelled through the "liveShare" DA transparently, because a user is free to add additional arguments to its launch config and they must arrive at the DA intact. The "__sessionID" is just one additional attribute that VS Code adds. So you should not need to know the potential arguments but you should pass everything unmodified. |
A more direct response to your previous question:
no, your adapter should just forward all DAP requests to whatever target DA you are proxying to. |
Understood. FYI, our node debugging proxy works, we are capable to launch from our code the node debug adapter by using the 'fork' technique we mimic. We are trying to figure out why the extension host debugging is not working when live share attempt to proxy. |
|
I did some more debugging of the EH debugging and saw one additional detail which might be the reason for the problem you are seeing: Launching of VS Code and attaching the debugger to it are done with two subsequent EH-DAs! First VS Code starts an EH-DA and then sends a "launch" request to it. Then the VS Code debugger of the first VS Code instance picks up the "attach" event, extracts the port number from it and starts another EH DA for attaching to the received port of the EH process. This (second) EH DA will be used for the course of the debug session. When the EH process needs to be restarted (which is frequently required for specific operations like opening a new folder), VS Code starts a new EH process, terminates the old EH process, and sends again the "attach" broadcast (which will be picked up again by the VS Code debugger and result in a new EH-DA). |
So, is more complex than i thought, and also multiple steps can fail. What i observe now is that a new vscode window is being created and also i notice the '[Extension Host Development]' title; So it seems right at first glance. Also i notice our vscode.DebugConfigurationProvider interface is being called multiple times. |
If the LiveShare-DA does not automatically pass all unknown attributes to the target DA, then please make sure that a |
Andre, I do see now a 'terminated' event coming from the node (the second one that attach through the port), it looks that it could not find a module, i suspect some working directories or env variables are not properly setup during our fork. Also i never found a restart: true option. |
I'm currently looking into the log. two comments:
|
I should have give you the other log from the first launch( will send you
once i arrive to the office), it basically does what you predict but then i
it did not receive any disconnect request, so it looks that is alive at the
point the other got terminated.
I feel we are super close, our PM will be really excited if we got this to
work, thanks again.
…On Fri, Aug 17, 2018 at 6:57 AM, Andre Weinand ***@***.***> wrote:
I'm currently looking into the log.
two comments:
-
It would be great if you could provide the node-debug2 trace as well.
Yes, it is included in the *.log as well but I want to compare it with a
trace from a non-LiveShare setup.
-
Instead of using the "mock-debug-extension" I suggest to use a simple
"hello world" extension. When using "mock-debug" the word "debug" appears
in too many places of logs and traces.
Creating an up-to-date "hello world" extension is simple:
https://code.visualstudio.com/docs/extensions/example-hello-
world#_generate-a-new-extension
<https://code.visualstudio.com/docs/extensions/example-hello-world#_generate-a-new-extension>
just run this:
npm install -g yo generator-code
yo code
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#56471 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEGBcaueaoGjiMEN2Om9j5WoV2ddrblFks5uRsvUgaJpZM4V-JHG>
.
|
Here is a run with a simplified 'hello-world' extension and now the 2 host adapter logs. The first one is shorter and it seems to launch the vscode EH, the second one is the attach. Please notice the first host adapter debug adapter is still alive and running, the second one get terminated abruptly with the java script runtime error. I suspect the EH vscode launch is missing some options to cause the java script engine to miss some other dependent modules to be found. |
Hi Andre, I will be OOF for 2 weeks, when i come back i will mention another issue i found that is not fully related to this problem but will be important to fix. |
Hi Rodrigo, great to hear that you managed to get EH debugging work under LiveShare. I've looked into the issue that VS Code sometimes relies on the debug type 'extensionHost'.
Ideally we should try to eliminate them. @isidorn we should brainstorm how we could do this. In general I see three ways to address this:
|
the identified issues will be addressed in the upcoming milestones. Since there is nothing to verify in August, I've added the "verified" label. |
Currently EH Debugging is not supported in Live Share.
With this issue we want to figure out what are the obstacles and how to address them.
The text was updated successfully, but these errors were encountered: