-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
domain: Make .domain
on async resources non-enumerable
#26210
Conversation
In particular, this comes into play in the node repl, which apparently enables domains by default. Whenever any Promise gets inspected, a `.domain` property is displayed, which is *very confusing*, especially since it has some kind of WeakReference attached to it, which is not yet a language feature. This change will prevent it from showing up in casual inspection, but will leave it available for use.
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
/cc @BridgeAR
9d0013e
to
ed34d24
Compare
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. It would be nice to add a test to it as well.
b233a06
to
084f7b2
Compare
Resume Build CI: https://ci.nodejs.org/job/node-test-pull-request/20973/ |
11c1de7
to
caa10ed
Compare
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!
Does this need tests?
What's the semver status of this? I don't think this is a major, but is it a minor or patch?
I’d call it a patch; imo it fixes confusion in the repl. |
caa10ed
to
311cec0
Compare
@ljharb would you mind adding a test? |
@ljharb If you want to only run domain tests, you can do |
Resume Build CI: https://ci.nodejs.org/job/node-test-pull-request/21223/ |
@BridgeAR I've added some; let me know if that's not what you had in mind :-) no dice :-/$ tools/test.py domain
Traceback (most recent call last):
File "tools/test.py", line 1766, in <module>
sys.exit(Main())
File "tools/test.py", line 1639, in Main
vm = context.GetVm(arch, mode)
File "tools/test.py", line 953, in GetVm
raise ValueError('Could not find executable. Should be ' + name)
ValueError: Could not find executable. Should be out/Release/node |
311cec0
to
9be90d9
Compare
This comment has been minimized.
This comment has been minimized.
@ljharb you have to compile Node.js first. Otherwise the tests can't run. |
@ljharb I just started a CI and it seems like there are linter errors. |
9be90d9
to
5aca8a1
Compare
@BridgeAR thanks, fixed. |
5aca8a1
to
3308853
Compare
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.
Do we really need all of these defineProperty
calls? If I am not mistaken we only have to set the property to enumerable false once and every following assignment will keep the descriptor in place.
@BridgeAR certainly you're right, but for all of the objects that aren't previously defined - like newly created resources, errors, event emitters, etc - it'd need the defineProperty every time. |
3308853
to
b1ae6f4
Compare
@BridgeAR updated |
CI https://ci.nodejs.org/job/node-test-pull-request/21481/ (:white_check_mark:) |
@misterdjules do you have any thoughts on this? |
As far as semver - this could be considered semver-major if someone was using the domains flag, and also enumerating an async resource, and then relying on |
Landed in 377c583 :) |
In particular, this comes into play in the node repl, which apparently enables domains by default. Whenever any Promise gets inspected, a `.domain` property is displayed, which is *very confusing*, especially since it has some kind of WeakReference attached to it, which is not yet a language feature. This change will prevent it from showing up in casual inspection, but will leave it available for use. PR-URL: #26210 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
In particular, this comes into play in the node repl, which apparently enables domains by default. Whenever any Promise gets inspected, a `.domain` property is displayed, which is *very confusing*, especially since it has some kind of WeakReference attached to it, which is not yet a language feature. This change will prevent it from showing up in casual inspection, but will leave it available for use. PR-URL: #26210 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
In particular, this comes into play in the node repl, which apparently enables domains by default. Whenever any Promise gets inspected, a `.domain` property is displayed, which is *very confusing*, especially since it has some kind of WeakReference attached to it, which is not yet a language feature. This change will prevent it from showing up in casual inspection, but will leave it available for use. PR-URL: nodejs#26210 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
In particular, this comes into play in the node repl, which apparently enables domains by default. Whenever any Promise gets inspected, a `.domain` property is displayed, which is *very confusing*, especially since it has some kind of WeakReference attached to it, which is not yet a language feature. This change will prevent it from showing up in casual inspection, but will leave it available for use. PR-URL: #26210 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@MylesBorins This is great! I ran into this recently when logging restify errors created from within a domain and we had to filter the And thanks for pinging me here, very much appreciated ❤️ |
In particular, this comes into play in the node repl, which apparently enables domains by default. Whenever any Promise gets inspected, a
.domain
property is displayed, which is very confusing, especially since it has some kind of WeakReference attached to it, which is not yet a language feature.This change will prevent it from showing up in casual inspection, but will leave it available for use.
I have not run the tests locally yet, because they're incredibly slow and I need to do other things with my machine, and because the last time I tried some of them failed on master anyways.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passescc @addaleax @devsnek