-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
lib,src: remove vm.runInDebugContext() #13295
lib,src: remove vm.runInDebugContext() #13295
Conversation
@@ -1,3 +1,4 @@ | |||
lib/internal/v8.js |
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.
The file is whitelisted because the V8 builtins don't lint. They're not legal JS syntax, eslint can't parse them.
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.
You should be able add comments by starting lines with #
– if you comment here in the PR, that sounds like a good indicator that it makes sense to do so. :)
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 are other lib/internal/v8
files whitelisted. I don't think we need a comment. But either way is fine.
lib/util.js
Outdated
const mirror = Debug.MakeMirror(value, true); | ||
function formatMapIterator(ctx, value, recurseTimes, visibleKeys, keys) { | ||
var nextRecurseTimes = recurseTimes === null ? null : recurseTimes - 1; | ||
var vals = previewMapIterator(value, 100); |
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 is a minor change in behavior here in that the preview is now limited to 100 elements. Before, it would show them all but that is (IMO) rather annoying with large maps and sets (and it's basically equivalent to printing the map or set minus the already iterated over elements.)
I'm planning to follow up with a PR that prints a nice "..." if there are more elements but I can restore the old behavior if people prefer that.
Documentation says Node 10+: https://github.com/nodejs/node/blob/master/doc/api/deprecations.md#dep0069-vmrunindebugcontextstring According to our deprecation policy, we should first emit a warning in Node 9 and remove the feature in Node 10 or higher. I guess it would have to be 10 here because V8 will remove the API by the end of the year. |
CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/845/ I don’t know about the reasons behind not going for a runtime deprecation in Node 8, I was just pretty sure I read somewhere that it was intentional. ¯\_(ツ)_/¯ |
@@ -1,3 +1,4 @@ | |||
lib/internal/v8.js |
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.
You should be able add comments by starting lines with #
– if you comment here in the PR, that sounds like a good indicator that it makes sense to do so. :)
doc/api/vm.md
Outdated
added: v0.11.14 | ||
--> | ||
|
||
> Stability: 0 - Deprecated. An alternative is in development. |
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.
You’ll also want to update the entry in deprecations.md
to say Type: End-of-Life
That doesn't apply to |
We really ought to have had a deprecation message added in 8.0.0 for this but it's rather too late now. If the plan is to remove it in 9.0, then we should get a runtime deprecation into an 8.x minor. |
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 context: the first part of this PR which removes the use of Debug Mirrors is, well, hacky as heck. But there is no other solution as I have found out when investigating #11875, other than convincing V8 devs to add C++ APIs for Map- and SetIterators.
@bnoordhuis can you attach a Fixes: https://github.com/nodejs/node/issues/11875
to the commit message as well?
lib/internal/v8.js
Outdated
while (n-- > 0) { | ||
const rc = %MapIteratorNext(it, out); | ||
if (rc === 0) break; | ||
if (rc === 1) result.push(out[0]); // it.keys() |
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 the 0/1/2/3 magic numbers be constants instead? V8 is using
define ITERATOR_KIND_KEYS = 1;
define ITERATOR_KIND_VALUES = 2;
define ITERATOR_KIND_ENTRIES = 3;
which looks good to me.
lib/internal/v8.js
Outdated
it = %MapIteratorClone(it); | ||
const result = []; | ||
const out = [,,]; | ||
while (n-- > 0) { |
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 a for-of loop be used directly on the cloned it
?
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 with nit
@@ -1,3 +1,4 @@ | |||
lib/internal/v8.js |
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 are other lib/internal/v8
files whitelisted. I don't think we need a comment. But either way is fine.
test/parallel/test-util-inspect.js
Outdated
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const util = require('util'); | ||
const vm = require('vm'); | ||
const { previewMapIterator } = require('internal/v8'); |
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 we test the SetIterator
as well?
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 didn't add a test here, I just updated an existing test that was using internals.
@fhinkel Do you have a better way to preserve the Iterator support w/o using V8 natives syntax? |
Maybe we could add these methods to the V8 API. Relying on intrinsic functions ( |
Yes, that's my longer-term goal. Using natives syntax is a short-term + least-effort solution. |
This needs a rebase. |
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 once #13295 (comment) is addressed.
@bnoordhuis do you still want to follow up on this? |
Updated. CI for a change: https://ci.nodejs.org/job/node-test-pull-request/10379/ |
I would like to formally request that we do NOT land this in Node 9. We have been migrating some of the code we use in https://github.com/GoogleCloudPlatform/cloud-debug-nodejs to the inspector module. At this point we do not think the inspector API is a complete replacement for the Since there is no pressing need to remove the API just yet, let's not accelerate the removal. |
👍 in waiting. |
This would need to be rebased now that the runtime deprecation has been merged. |
Ping @bnoordhuis this could land after a rebase |
ef78a22
to
fce7077
Compare
@@ -1,15 +1,7 @@ | |||
'use strict'; | |||
|
|||
// Hack to load the js-yaml module from eslint. |
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.
unrelated 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.
grr... this one is becoming quite annoying.
@bnoordhuis ... the extraneous js-yaml change is causing CI to fail on this. |
fce7077
to
76796b7
Compare
With js-yaml change undone: https://ci.nodejs.org/job/node-test-pull-request/11679/ |
This paves the way for removing `vm.runInDebugContext()`. Inspection of Map and Set iterators is now done through V8 instrinsics. Fixes: nodejs#11875 PR-URL: nodejs#13295 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
The V8 API it is based on is deprecated and scheduled for removal later this year. Remove it. PR-URL: nodejs#13295 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
76796b7
to
6f724e1
Compare
Btw: This breaks That’s nothing we can do anything about, we need this patch in order to avoid breakage ourselves, so it’s graceful-fs that needs to work around this, but I wanted to leave that information here. |
The V8 API it is based on is deprecated and scheduled for removal later this year. Remove it. PR-URL: nodejs#13295 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
The V8 API it is based on is deprecated and scheduled for removal later this year. Remove it.
The first commit replaces the
Debug.MakeMirror()
call in lib/util.js with something else.The most important reason for doing this is of course to have a deprecation warning-free build again!