-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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: support non-main contexts #14465
Conversation
@eugeneo do you know if the patch will be available in mainline V8 5.9 or 6.0? |
src/inspector_agent.cc
Outdated
return; | ||
std::ostringstream name; | ||
name << "VM Context " << next_context_number_++; | ||
client_->contextCreated(context, name.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.
Can you decouple VM from Inspector Agent? Also, can you add support for customizing VM context name and origin from JS?
@refack looks like V8 commit got rolled back tonight. This PR is on hold until the issue is resolved... @TimothyGu should I make context registration happen in JS land in lib/vm.js? Re: name - what is your suggestion? I can add a symbol that is can be added to a sandbox object - e.g: const sandbox = {};
sandbox[require('inspector').CONTEXT_NAME] = 'my context';
const ctx = require('vm').createContext(sandbox); Surely, it will be optional. |
I'd prefer them to be options to I'm fine with registering it in C++. I just want things in the Agent to be usable by everything rather than by only one thing, and want Agent to include support for every param Inspector has to offer, namely |
A new version of the V8 patch landed, should not get rolled back now... I backported it and rebased this pull request. @TimothyGu I am still not sure what you are proposing. Should those options come through the vm.js module or you want the users to explicitly opt-in the contexts into inspector tracking? |
CI link: https://ci.nodejs.org/job/node-test-pull-request/9459/ I believe this PR is ready for the review. It does not expose any new API and is not visible to the users, except that breakpoints will start working in new contexts. If there is a need to add an API to name the contexts, etc - that can be done separately at the later time. |
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.
LGTM
src/node_contextify.cc
Outdated
@@ -357,6 +357,7 @@ class ContextifyContext { | |||
|
|||
static void WeakCallback(const WeakCallbackInfo<ContextifyContext>& data) { | |||
ContextifyContext* context = data.GetParameter(); | |||
|
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 assume this is left over from a previous iteration?
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.
That was a line for a printf to check if the context is GCed :)
Thanks, I removed it.
CI failures do not seem to be related to this change. V8 patch will be in V8 6.1 release. |
V8 CI: https://ci.nodejs.org/job/node-test-commit-v8-linux/838/ @eugeneo what are the chances of upstream approving a backport to 6.0? Normally we bump the V8 version when floating a patch backwards. But given that V8 6.0 is still supported upstream, it is not safe to do given that upstream will be bumping versions too. (/cc @targos in case we bring in another update of 6.0 – we will need to re-float this at that time.) If upstream backports to 6.0, this problem goes away. |
Could we have the patch merged to 6.1? |
@eugeneo Is the |
CC: @ak239 Alexei, can you help with the information about V8 version and the backport? |
I see console unconditionally added in master, even without this patch.E.g. |
Ok, let me split problems: console and non-main context inspection are two different problems. About console: |
Per the process, this PR can be landed now (48 hours had passed, there's LGTM). Any last minute objections? |
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.
My original concern about console
has resolved itself in 6.0 it seems.
What is the status of this, how long may it take before this and the V8 patch is propagated to a release? |
@Pajn V8 patch is still there :) - v8/v8@f19b889 |
Original commit message: [inspector] support for cases when embedder doesn't call contextDestroyed Node.js doesn't have good place to call contextDestroyed. We need to cleanup everything on our side to allow clients to not call contextDestroyed method. [email protected],[email protected] Bug: none Change-Id: Ibe3f01fd18afbfa579e5db66ab6f174d5fad7c82 Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_chromium_rel_ng Reviewed-on: https://chromium-review.googlesource.com/575519 Reviewed-by: Dmitry Gozman <[email protected]> Commit-Queue: Aleksey Kozyatinskiy <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#46849} Reviewed-on: https://chromium-review.googlesource.com/596549 Cr-Commit-Position: refs/heads/master@{#47060} Ref: https://chromium.googlesource.com/v8/v8.git/+/f19b889be801bdebc04c49090e37c787f7ba8805 PR-URL: #14465 Reviewed-By: Jan Krems <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Aleksey Kozyatinskiy <[email protected]>
This enables inspector support for contexts created using the vm module. PR-URL: #14465 Reviewed-By: Jan Krems <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Aleksey Kozyatinskiy <[email protected]>
Notable changes * **HTTP2** * Experimental support for the built-in `http2` has been added via the `--expose-http2` flag. [#14239](#14239) * **Inspector** * `require()` is available in the inspector console now. [#8837](#8837) * Multiple contexts, as created by the `vm` module, are supported now. [#14465](#14465) * **N-API** * New APIs for creating number values have been introduced. [#14573](#14573) * **Stream** * For `Duplex` streams, the high water mark option can now be set independently for the readable and the writable side. [#14636](#14636) * **Util** * `util.format` now supports the `%o` and `%O` specifiers for printing objects. [#14558](#14558) PR-URL: #14811
Notable changes * **HTTP2** * Experimental support for the built-in `http2` has been added via the `--expose-http2` flag. [#14239](#14239) * **Inspector** * `require()` is available in the inspector console now. [#8837](#8837) * Multiple contexts, as created by the `vm` module, are supported now. [#14465](#14465) * **N-API** * New APIs for creating number values have been introduced. [#14573](#14573) * **Stream** * For `Duplex` streams, the high water mark option can now be set independently for the readable and the writable side. [#14636](#14636) * **Util** * `util.format` now supports the `%o` and `%O` specifiers for printing objects. [#14558](#14558) PR-URL: #14811
Notable changes * **HTTP2** * Experimental support for the built-in `http2` has been added via the `--expose-http2` flag. [#14239](nodejs/node#14239) * **Inspector** * `require()` is available in the inspector console now. [#8837](nodejs/node#8837) * Multiple contexts, as created by the `vm` module, are supported now. [#14465](nodejs/node#14465) * **N-API** * New APIs for creating number values have been introduced. [#14573](nodejs/node#14573) * **Stream** * For `Duplex` streams, the high water mark option can now be set independently for the readable and the writable side. [#14636](nodejs/node#14636) * **Util** * `util.format` now supports the `%o` and `%O` specifiers for printing objects. [#14558](nodejs/node#14558) PR-URL: nodejs/node#14811
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
inspector: non-main contexts are now reported to an inspector.
This is a suggested implementation of non-main contexts support for the inspector. It is based on a recently landed V8 patch that is included into this pull request.
This solution has a number of shortcomings that need to be fixed in V8:
This pull request is a suggested alternative to #14231 - note that 14231 also adds the inspector console.
CC: @ak239
refack added: link to V8 patch's Gerrit