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

V8 Inspector ignores/squelches evaluation in console panel #9188

Closed
akatechis opened this issue Oct 19, 2016 · 9 comments
Closed

V8 Inspector ignores/squelches evaluation in console panel #9188

akatechis opened this issue Oct 19, 2016 · 9 comments
Labels
inspector Issues and PRs related to the V8 inspector protocol

Comments

@akatechis
Copy link

Version: v6.9.0
Platform: Windows 10 64bit Home (Running node in Git Bash MINGW64_NT-10.0 Alex 2.6.0(0.304/5/3) 2016-09-09 09:46 x86_64 Msys)
Subsystem: V8 Inspector
Chrome version: Version 53.0.2785.143 m

Issue: Can't evaluate expressions in inspector's console.

Reproduce: node --inspect -e "var q = { foo: 'bar'}; while(1);"

After opening the inspector window, I type q into the console panel, expecting to see {foo: "bar"} as the evaluation result, but instead see nothing. My own input is also cleared away, as if I had never typed it at all. I also tried process and module to the same effect.

@mscdex mscdex added the inspector Issues and PRs related to the V8 inspector protocol label Oct 19, 2016
@mscdex
Copy link
Contributor

mscdex commented Oct 19, 2016

/cc @nodejs/v8-inspector

@alexkozy
Copy link
Member

To evaluate something in console we use Runtime.evaluate protocol command. We have two different strategy to run command:

  • run command as regular embedder task (we use it for most protocol commands in chrome),
  • request V8 interrupt and run command inside of interrupt callback (use this for part of Debugger command like Debugger.pause in chrome).

I'm not sure how we run commands in Node.js, I think that @eugeneo knows everything about it.

V8 interrupt allows us to run code even in most kind of nested loop but this technique doesn't solve all the problems because V8 able to call interrupt callback only at the moment of function call and I hope in some special places like assignment in for-loop. If you have infinite loop without functions calls (or with inlined by optimizer function calls) and without any assignments then interrupt callback will never be called and V8 inspector will never get a chance to run protocol command.
We can try to improve this scenario.

@eugeneo
Copy link
Contributor

eugeneo commented Oct 19, 2016

I haven't been able to reproduce this issue - I wonder if it is Windows-specific. I will need to add a test case and see if it is intermittent or platform dependent.

@akatechis
Copy link
Author

@ak239 , I am able to reproduce this even without an infinite loop:

main.js

var http = require("http");
http.createServer(function (req, res) {
  res.end("Hello");
}).listen(9876);

and then, node --inspect main.js

After attaching, I have tried sending code via the console as well, as by setting a breakpoint inside the request handler, opening the page, and breaking on that line, then trying to evaluate things like res, res.write, res.end and even process

I also tried modifying the code to res.end(__dirname); and then trying to evaluate __dirname and I still am unable to get any kind of output.

As for OS, I'm on Windows 10 Home Edition, 64 bit, build 14393.321

@eugeneo
Copy link
Contributor

eugeneo commented Oct 20, 2016

Looks like the issue is Windows specific.

Here's what I'm seeing:

  1. I built Node 6.9.1 from the sources (git checkout v6.9.1 && ./configure && make -j16 node)
  2. Copied the snippet from previous comment to /tmp/main.js
  3. ./node --inspect /tmp/main.js
  4. Opened devtools and set a breakpoint on line 3 ("res.end("Hello");")
  5. Opened localhost:9876 in browser, verified the breakpoint had been hit.
  6. In the console, typed "res".

Following object was printed in the console: "ServerResponse {domain: null, _events: EventHandlers, _eventsCount: 1, _maxListeners: undefined, output: Array[0]…}"

@akatechis
Copy link
Author

Update: I am also able to reproduce the issue if I run node --inspect main.js using cmd.exe and PowerShell, in addition to Git Bash. Seems like it's a windows thing, rather than the shell environment I'm using.

@eugeneo
Copy link
Contributor

eugeneo commented Nov 3, 2016

Does it work if you replace "localhost" in the URL with the "127.0.0.1"?

@akatechis
Copy link
Author

Looks like it works:
I loaded the inspector at:
chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/28566c8c-1d60-4a42-89f1-25474d411575

Set a breakpoint @ res.end(...);, typed res into the console and got the following:
ServerResponse {domain: null, _events: EventHandlers, _eventsCount: 1, _maxListeners: undefined, output: Array[0]…}

@eugeneo
Copy link
Contributor

eugeneo commented Nov 3, 2016

It looks like this is a duplicate of #9382

@eugeneo eugeneo closed this as completed in a41b41a 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

No branches or pull requests

4 participants