External debug tools not working on NW.js
See original GitHub issueWe are trying to debug a simple web app with NW.js for instance, the Angular2 “Tour of Heroes” tutorial app and the debugger isn’t able to attach to the app running on NW.js.
For this specifc repro case, we tried VSCode from Microsoft.
The following works fine:
- Debug Client java script (angular2 code) - VSCode Launch chrome or we can attach to an existent running tab
- Debug server script (node.js code) - VSCode launch node.js instance or it can attach to an existent instance.
All those cases we were able to debug both JS and TS (with sourceMaps enabled).
The problem:
If we instead of use vanilla node.js to host the app by launch and/or attach VSCode to it, we try to run it on NW.js, we get the following errors in the output:
If VSCode start NW.js:
›OS: win32 ia32
›Node version: v5.10.0
›Adapter version: 0.0.5
›initialize({"adapterID":"chrome","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true})
›launch({"name":"NW.js","type":"chrome","request":"launch","runtimeExecutable":"nw.exe","runtimeArgs":["c:\\Dev\\Samples\\dietsample\\data","--enable-logging","--mixed-context","--remote-debugging-port=9222"],"sourceMaps":true,"diagnosticLogging":true,"noDebug":false})
›WARNING: "webRoot" is not set - if resolving sourcemaps fails, please set the "webRoot" property in the launch config.
›spawn('nw.exe', ["--remote-debugging-port=9222","--no-first-run","--no-default-browser-check","c:\\Dev\\Samples\\dietsample\\data","--enable-logging","--mixed-context","--remote-debugging-port=9222"])
›Attempting to attach on port 9222
›Error: Got response from target app, but no valid target pages found
at Object.errP (C:\Users\gutem\.vscode\extensions\msjsdiag.debugger-for-chrome-0.3.1\node_modules\vscode-chrome-debug-core\out\src\utils.js:209:13)
at C:\Users\gutem\.vscode\extensions\msjsdiag.debugger-for-chrome-0.3.1\node_modules\vscode-chrome-debug-core\out\src\chrome\chromeConnection.js:178:26
at process._tickCallback (internal/process/next_tick.js:103:7)
›To client: {"seq":0,"type":"response","request_seq":2,"command":"launch","success":false,"message":"[debugger-for-chrome] Got response from target app, but no valid target pages found"}
NW.js starts, load the ANgular app and is killed. Looks like VSCode kill it if it is unable to connect to it after some time. The connect is made to the port 9222 but it looks like it is unable to find the app on it Error: Got response from target app, but no valid target pages found
If we use attach, the error is the same, except that it doesn’t start nw.exe since I do it manually before start the debugger.
This is the version of nw.js we are using:
nw.js v0.15.0
Node v6.2.0
Chromium 51.0.2704.63
commit hash: 73bdfec-d5bd333-bc975ec-3233243
We also made tests with Electron and it worked pretty fine.
Just for the sake of information, the configs used in the VSCode debugger(https://github.com/Microsoft/vscode-chrome-debug) are the following:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch index.html with sourcemaps",
"type": "chrome",
"request": "launch",
"file": "${workspaceRoot}/index.html",
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
},
{
"name": "Launch localhost with sourcemaps",
"type": "chrome",
"request": "launch",
"url": "http://localhost:9222",
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
},
{
"name": "Attach with sourcemaps",
"type": "chrome",
"request": "attach",
"port": 9222,
"sourceMaps": true,
"webRoot": "${workspaceRoot}",
"diagnosticLogging": true
},
{
"name": "Electron",
"type": "chrome",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/electron-prebuilt/dist/electron.exe",
"runtimeArgs": [
"${workspaceRoot}",
"--enable-logging",
"--remote-debugging-port=9222"
],
"sourceMaps": true,
"diagnosticLogging": true
},
{
"name": "NW.js",
"type": "chrome",
"request": "launch",
"runtimeExecutable": "nw",
"runtimeArgs": [
"${workspaceRoot}",
"--mixed-context",
"--remote-debugging-port=9222"
],
"sourceMaps": true,
"diagnosticLogging": true
}
]
}
The closest thing we have from NW.js is Electron and it works just fine… Node.js and Chrome also work fine with VSCode, so I could only assume that is something related to nw.js itself.
Can you help us with that?
Thanks
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (5 by maintainers)
Top GitHub Comments
close since the issue is not in NW.
@galvesribeiro BTW to set breakpoints, you should set
webRoot
to your application root folder and hackisExtensionScript
to always returnfalse
.