question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

External debug tools not working on NW.js

See original GitHub issue

We 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:

  1. Debug Client java script (angular2 code) - VSCode Launch chrome or we can attach to an existent running tab
  2. 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:closed
  • Created 7 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
rogerwangcommented, Jun 2, 2016

close since the issue is not in NW.

2reactions
ghostoycommented, Jun 1, 2016

@galvesribeiro BTW to set breakpoints, you should set webRoot to your application root folder and hack isExtensionScript to always return false.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging with DevTools - NW.js Documentation
NW.js is running in Separate Context Mode by default. To debug Node.js modules, you can right click the app and choose “Inspect Background...
Read more >
Run/Debug Configuration: NW.js - JetBrains Rider
Run External tool: select to run an external application. In the dialog that opens, select one or multiple applications you want to run....
Read more >
How to use devtool in node NW? - Stack Overflow
open DevTools programmatically using NW.js API win.showDevTools(). Or... Remote ... For example, by running nw --remote-debugging-port=9222, ...
Read more >
Let's Debug Your Application | NW.js Essentials
NW.js DevTools are remote debugging tools where data is transferred through a ... implementing the device emulator would clearly not serve any purpose....
Read more >
Debugging - Getting Started - Node.js
These security policies disallow connecting to a remote debug server by specifying the hostname. You can work-around this restriction by specifying either the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found