Open jeanlemotan opened 3 years ago
Hi @jeanleflambeur,
Currently, this example does not work with VSCode because VSCode sends additional GET
HTTP request to get the version of the server and this example does not act as an HTTP Server.
As far as I remember VSCode sends /json
and /json/version
to the HTTP server to get the URL of WebSocket server and HTTP server responds something like as follows:
{
"Browser": "V8Example/v1",
"Protocol-Version": "1.1",
"V8-Version": "8.110.9",
"webSocketDebuggerUrl": "ws://127.0.0.1:9090/ws"
}
So, in order to make it work with VSCode or other IDEs, your server should support both HTTP and WebSocket requests.
Thanks for your response. In the mean time I managed to get it working fully using this launch params:
{
"configurations": [
{
"name": "Attach",
"port": 9006,
"websocketAddress" : "ws://127.0.0.1:9006",
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node",
"localRoot": "${workspaceFolder}",
"remoteRoot": "/scripts",
"sourceMaps": true
}
]
}
Turns out the node debugger supports setting the websocketAddress directly so you can skip the HTTP protocol entirely. The other thing to do is to embed this in the global context:
const char* nodeDebuggerStuff = R"(
let process =
{
pid: 1,
version: 16,
arch: "x86",
env: {}
})";
Node.js adds this 'process' object to the global scope and the debugger tries to retrieve this info and if it's not there it gets stuck in a loop asking for this.
The next thing is to solve the relative/absolute paths between the vscode and the embedded V8. You do this with the localRoot/removeRoot keys in launch.json. They are used to convert between local vscode paths and remote (embedded) paths.
So now I have a very functional vscode debugging session for an embedded v8. Thanks a lot for your code btw - it helped me a lot to get started.
That's good to know that VSCode now supports WebSocket server directly! At that time, I created that example project that was not possible.
Good to hear that this example helped you :)
Hi,
Did you manage to make this work with VSCode node debugger?
I keep getting handshake errors and I cannot understand why. Debugging in Chrome DevTools works just fine on the other hand.
Thanks!