-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
inspector: no URLs when the debugger is connected #8919
Conversation
(linter fail is my bad -- reimaging one of the vm's) |
Windows failures do not seem to be caused by this change. |
CI: https://ci.nodejs.org/job/node-test-commit/5605/ - seems to be as green as possible |
inspector_write(socket, header, header_len); | ||
inspector_write(socket, response, len); | ||
inspector_write(socket, &response[0], response.length()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response.c_str() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used data() - there's is no need for null-terminated string.
} | ||
json << "\n} ]"; | ||
return json.str(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A homegrown JSON serializer seems like a recipe for disaster. Is there a way to use V8's JSON.stringify?
If nothing else, FormatJSON()
is something of a misnomer because you need to escape the values manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v8::JSON::stringify requires V8 context. This code runs on a dedicated (non-V8) thread, can be ran early in the startup (e.g. if the node is started with --debug-brk), needs to run when V8 is suspended on a breakpoint, etc.
I renamed to MapToString. I hope we will not need a "full" JSON serializer :)
inspector_write(socket, header, header_len); | ||
inspector_write(socket, response, len); | ||
inspector_write(socket, response.data(), response.length()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the tiniest of nits but we use string.size()
everywhere else. Can you use it here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Done.
response["User-Agent"] = | ||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36" | ||
"(KHTML, like Gecko) Chrome/45.0.2446.0 Safari/537.36"; | ||
response["WebKit-Version"] = "537.36 (@198122)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my education: is this header necessary and if so, what does it signify?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for protocol clients, that are trying to figure out protocol version from this field. It is a wrong check, but apparently some clients did it at the time when the integration was initially implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's already obsolete baggage, why add it? I assume those clients you mention will need to be updated anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Removed the fields. VSCode and Chrome devtools seem unaffected, I do not know what was the tool that used to fail.
6f558a7
to
0e6750d
Compare
@bnoordhuis Thank you for the review. I uploaded a new version of the patch. |
Fully green CI: https://ci.nodejs.org/job/node-test-pull-request/4583/ :) |
@bnoordhuis PTAL when you get a chance. |
I commented a few hours ago. Did anything change? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bnoordhuis Thank you for the review. I removed those 2 fields and did some manual testing.
New CI: https://ci.nodejs.org/job/node-test-pull-request/4597/
response["User-Agent"] = | ||
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36" | ||
"(KHTML, like Gecko) Chrome/45.0.2446.0 Safari/537.36"; | ||
response["WebKit-Version"] = "537.36 (@198122)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Removed the fields. VSCode and Chrome devtools seem unaffected, I do not know what was the tool that used to fail.
By convention, inspector protocol targets do not advertise connection URLs when the frontend is already connected as multiple inspector protocol connections are not supported. PR-URL: #8919 Reviewed-By: Aleksey Kozyatinskiy <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Landed as da184f4 |
Fix the following compile-time warning: ../src/inspector_agent.cc:175:19: warning: 'const string node::inspector::{anonymous}::to_string(uint64_t)' defined but not used [-Wunused-function] const std::string to_string(uint64_t number) { Refs: nodejs#8919
By convention, inspector protocol targets do not advertise connection URLs when the frontend is already connected as multiple inspector protocol connections are not supported. PR-URL: #8919 Reviewed-By: Aleksey Kozyatinskiy <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
@eugeneo I attempted to backport this to v6.x but it broke the test suite
thoughts? |
@thealphanerd I tried cherrypicking this change on top of v6.x-staging - tests seem to pass - https://github.com/eugeneo/node/tree/v6.x-staging |
@thealphanerd - I've also started CI here to see if this is something platform specific. |
@thealphanerd - I see no relevant CI failures - https://ci.nodejs.org/job/node-test-commit/6044/ |
By convention, inspector protocol targets do not advertise connection URLs when the frontend is already connected as multiple inspector protocol connections are not supported. PR-URL: #8919 Reviewed-By: Aleksey Kozyatinskiy <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
@eugeneo I've landed it now... must have been something else that landed in the mean time that fixed it |
By convention, inspector protocol targets do not advertise connection URLs when the frontend is already connected as multiple inspector protocol connections are not supported. PR-URL: #8919 Reviewed-By: Aleksey Kozyatinskiy <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
inspector
Description of change
By convention, inspector protocol targets do not advertise connection
URLs when the frontend is already connected as multiple inspector
protocol connections are not supported.