Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
embedding: allow creating context within inspectable node::Environment #31424
embedding: allow creating context within inspectable node::Environment #31424
Changes from all commits
00e7108
5ddcae8
72f2a0e
f138b0e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
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 would disagree, since there are three major problems in what you have described:
v8_inspector::V8Inspector
is accessed must be aware both in compile-time and in runtime whether an inspector agent actually exists (currentlynode::Environment
does that);v8_inspector::V8Inspector::ContextCreated()
is intended to use from the context-creating functions. It is not a notification and it will happily re-assign thedebug_context_id
leading to undefined behavior for any outstanding requests from the frontend with the olddebug_context_id
.v8::Isolate::SetPrepareStackTraceCallback()
. If the environment does not handle that there should be another class in the hierarchy:node::MultiIsolatePlatform -> (per-isolate object) -> node::Environment
. This would require major untangling of thenode::Environment
and it is not related to the main goal here: creating a new context.I think that hiding the context creation process steps from the API is way more stable than exposing the inspector agent to the embedder. Currently
node::Environment
perform some per-isolate processes likev8::Isolate::SetPrepareStackTraceCallback
. In the V8 enginev8::Context
objects are part ofv8::Isolate
, and there are certain API that are per-isolate. Therefore, ifnode::Environment
does not handle the per-isolate API, there must be another class that handles it (andnode::Environment
would probably contains shared pointer towards it). And since the inspector agent would always be hidden within an instance of a node's class (see the first two points above), the best approach for the context creation process would be to havenode::NewContext
that accepts the node's per-isolate object and perform node's specific initialization (like reporting the context to its inspector agent).For the current minor version,
node::Environment
is still per-isolate, and the exposed function signature allow proper initialization with provided embedder'sv8::ObjectTemplate
while reporting to the inspector agent is not exposed and how it is done can be changed in the future versions.The only problem is the
initialize
argument. To become future-proof compatible, it would be better if the third parameter is some white-box (publicly exposed) structure, that can be expanded with other properties in the future versions.