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

node --inspect: dev tools console not working #9382

Closed
atif089 opened this issue Oct 31, 2016 · 16 comments · Fixed by #9451
Closed

node --inspect: dev tools console not working #9382

atif089 opened this issue Oct 31, 2016 · 16 comments · Fixed by #9451
Labels
inspector Issues and PRs related to the V8 inspector protocol

Comments

@atif089
Copy link

atif089 commented Oct 31, 2016

Version: 6.9.1 and 7.0
Platform: Windows 7 x64 (Chrome 54.0.2840.71 m)
Subsystem:

  • Create a file test.js with console.log("Hello World");
  • Run node --inspect --debug-brk test.js

On the console tab, I don't see any input field. When I press escape and open the smaller console tab, I have suggest for input, but I can't execute code.

The latter works when I change the URL query param from ws=localhost:9229/node to ws=127.0.0.1:9229/node

I made a small video to display the problem that I have been facing.

@eugeneo
Copy link
Contributor

eugeneo commented Oct 31, 2016

This is not a Node.js bug but a Chrome DevTools issue.

@atif089
Copy link
Author

atif089 commented Oct 31, 2016

@eugeneo Shall I post it at bugs.chromium.org ?

@eugeneo
Copy link
Contributor

eugeneo commented Oct 31, 2016

Yes, please. Can you also try Node 7 - either nightly build or build from the sources? It uses newer devtools, the bug might not be reproducible there.

@atif089
Copy link
Author

atif089 commented Oct 31, 2016

Sure, I can try from the nightly build it in an hour and will post my results here. I'm a meagre front end developer so I might not be able to build it myself from the sources.

@mscdex mscdex added the inspector Issues and PRs related to the V8 inspector protocol label Oct 31, 2016
@atif089
Copy link
Author

atif089 commented Oct 31, 2016

@eugeneo Yep! The console is working fine in the v8.0.0-nightly201610310e92bb99c6 release. I can see the blue arrow and the input box.

But one original problem which was also there in the previous issue still remains which is that I need to replace localhost with 127.0.0.1 otherwise the console would not print statement.

For example the URL

chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=localhost:9229/0bd7
6823-b73d-4b59-b4c0-aac52bbbb0a5`

Becomes

chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/0bd7
6823-b73d-4b59-b4c0-aac52bbbb0a5`

@eugeneo
Copy link
Contributor

eugeneo commented Oct 31, 2016

This sounds like something odd in Windows networking - so it has to be looked into.

@atif089
Copy link
Author

atif089 commented Nov 2, 2016

I tried digging around a bit more on this issue. I'm using this plugin called Inspect Process.

It tries to read the debugger URL and launch debug tools in a new process (Source). I was expecting the console to work when I replaced localhost with 127.0.0.1 and launch the process. But it still doesn't work and I face the same problem.

The only way I could see this working is when I manually open Chrome and then paste the debug URL replacing localhost with 127.0.0.1.

I now feel maybe there is something wrong with my Windows itself or my copy of Chrome so today I will create a fresh Windows 7 VM and then try it inside the VM and report it here.

@atif089
Copy link
Author

atif089 commented Nov 2, 2016

@eugeneo tried it inside a new Windows VM

  • Windows 7 x86
  • Node v7.0.0

everything worked perfectly fine for the first time. And then from the second time onwards the same problem reflects, i.e using 127.0.0.1 instead of localhost

@eugeneo
Copy link
Contributor

eugeneo commented Nov 3, 2016

Looks like some Windows7 setups are not able to resolve localhost. This can either be addressed with changing the Windows setup or by using 127.0.0.1 as a host name.

@atif089
Copy link
Author

atif089 commented Nov 3, 2016

@eugeneo Thanks for pushing the localhost -> 127.0.0.1 change. Do you know when does it normally get merged into the nightly build?

Also, one last question about localhost not resolving on Windows 7 setups. Did you mean the resolution is setting up the line 127.0.0.1 localhost inside the system32/drivers/etc/hosts file? Because that doesn't work either.

However localhost in the browser points to the webserver if it's running.

@eugeneo
Copy link
Contributor

eugeneo commented Nov 3, 2016

@atif089 I have never being able to reproduce this problem as it seems like some pecularity with Windows7 setups and/or specific network environments. Some browsers might be using different resolution facilities so the results may differ ever so slightly.

Right now I need to wait 48 hours before actually submitting this patch (there might be some issues that I have not thought about so I would like other Node contributors take a look). So it should be in by the Tuesday build.

@atif089
Copy link
Author

atif089 commented Nov 3, 2016

@eugeneo Weird part is that I use this plugin called inspect-process which uses chrome driver and only launches an instance of DevTools.

I changed it's source to replace localhost with 127.0.0.1 so that it looks like this

proc.stderr.on('data', (data) => {
      let dataStr = data.toString();
      const isListening = dataStr.startsWith('Debugger listening on port');
      const isAttached = dataStr.startsWith('Debugger attached');
      const isComplete = dataStr.startsWith('Waiting for the debugger to disconnect');

      if (isListening) {
        dataStr = dataStr.replace("localhost", "127.0.0.1");
        return devtools.open(dataStr.substring(dataStr.indexOf('chrome-devtools')));

      } else if (isComplete) {

The problem still exists.

But if I manually open Google Chrome and then paste that link with 127.0.0.1, it works.

Video -> https://www.youtube.com/watch?v=0mll_sCzSAI

I posted this because maybe it might not work even after your last commit due to this problem.

@atif089
Copy link
Author

atif089 commented Nov 3, 2016

Quickly tested on a Windows 8 and Windows 10 VM. And it exists there too. I also see this error in console

[2744:7908:1104/003631:ERROR:CONSOLE(1)] "Uncaught ReferenceError: DevToolsAPI is not defined", source:  (1)
[2744:7908:1104/003631:ERROR:CONSOLE(4461)] "Request Log.enable failed. {"code":-32601,"message":"'Log.enable' wasn't found"}", source: chrome-devtools://devtoo
ls/bundled/inspector.js (4461)

@atif089
Copy link
Author

atif089 commented Nov 7, 2016

Hi @eugeneo,

I tried using Visual Studio Code's debugger last weekend and it seems to work without any problem. Does it work differently than the Chrome's debug tools?

@eugeneo
Copy link
Contributor

eugeneo commented Nov 7, 2016

Probably they are not using "localhost" - just the IP address.

On Mon, Nov 7, 2016 at 2:55 AM Mohammed Ameenuddin Atif <
notifications@github.com> wrote:

Hi @eugeneo https://github.com/eugeneo,

I tried using Visual Studio Code's debugger last weekend and it seems to
work without any problem. Does it work differently than the Chrome's debug
tools?


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#9382 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AARkrWcwk4ON9QKAsRFbKX7iOaeEMjiGks5q7wOegaJpZM4KlNjB
.

@atif089
Copy link
Author

atif089 commented Nov 7, 2016

evanlucas pushed a commit that referenced this issue Nov 7, 2016
There are multiple reports of Windows7 not being able to resolve
localhost on some setups (web search also confirms that). This change
will advertise "127.0.0.1" as inspector host name.

Fixes: #9382
Fixes: #9188
PR-URL: #9451
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
MylesBorins pushed a commit that referenced this issue Nov 22, 2016
There are multiple reports of Windows7 not being able to resolve
localhost on some setups (web search also confirms that). This change
will advertise "127.0.0.1" as inspector host name.

Fixes: #9382
Fixes: #9188
PR-URL: #9451
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inspector Issues and PRs related to the V8 inspector protocol
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants