-
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: do not add 'inspector' property #12656
Conversation
lib/internal/bootstrap_node.js
Outdated
return; | ||
function installInspectorConsoleIfNeeded(globalConsole) { | ||
var wrappedConsole = NativeModule.require('console'); | ||
var inspector = process.binding('inspector'); |
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.
const
?
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.
Done, thanks!
src/inspector_agent.cc
Outdated
|
||
|
||
|
||
void InspectorWrapConsoleCall(const FunctionCallbackInfo<Value>& info) { |
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.
Does this method (and ConsoleCall
) need to be written in C++?
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 there is a way to not expose internal JavaScript function in stack trace then it's not necessary.
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.
Yeah, there’s Error.captureStackTrace()
specifically for that.
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.
On inspector side we use native v8 API: v8::StackTrace::CurrentStackTrace
instead of JS Error.captureStackTrace
and it's really important to have correct top frame for console messages since we use its location as message location.
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.
@addaleax I am not sure how Error.captureStackTrace can be used here.
Inspector records stack traces for all console messages. You can see in in Chrome DevTools where there is a hyperlink to the right of every log record.
Having a native wrapper ensures that Inspector records the place where the native wrapper is called (e.g. the user code, as expected). If you make that wrapper a JS function then that function will be called, meaning there is the same top frame for every console call.
I did a couple prototypes and I do not see how I can remove the native wrapper for the console calls.
src/inspector_agent.cc
Outdated
|
||
|
||
|
||
void InspectorWrapConsoleCall(const FunctionCallbackInfo<Value>& info) { |
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 there is a way to not expose internal JavaScript function in stack trace then it's not necessary.
call_args.push_back(args[i]); | ||
} | ||
|
||
env->inspector_agent()->PauseOnNextJavascriptStatement("Break on start"); |
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.
Just idea, maybe we need a way to provide something like blackbox this function method then we can blackbox caller and have just schedule Pause OnNextStatement method.
'inspector' property is not an official API and should not be published on process object, where the user may discover it. This change was extracted from #12263 that will be focused on creating JS bindings. PR-URL: #12656 Reviewed-By: Aleksey Kozyatinskiy <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
Landed as 3f48ab3 |
'inspector' property is not an official API and should not be published on process object, where the user may discover it. This change was extracted from nodejs#12263 that will be focused on creating JS bindings. PR-URL: nodejs#12656 Reviewed-By: Aleksey Kozyatinskiy <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
Should this be backported to |
@eugeneo most (all?) of the inspector work on master isn't landing on 6.x, should it? Is there any reason we should let the inspector on 6.x and 8.x (and later) diverge? For example, is the underlying V8 inspector implementations too different for us to be able to keep them in sync? cc: @nodejs/lts |
@sam-github there had been divergence in the command line options, console output. Also, there was JS API added. My understanding is that all of that is considered an API breaking change and can't be backported. |
'inspector' property is not an official API and should not be published
on process object, where the user may discover it.
This change was extracted from #12263
that will be focused on creating JS bindings.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
inspector: new object is not created and insteaad JS bindings are defined.