Skip to content
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

src: allow getting Symbols on process.env #9631

Closed
wants to merge 1 commit into from

Conversation

addaleax
Copy link
Member

Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

process

Description of change

1aa595e introduced a throw for accessing Symbol properties of process.env. However, this breaks util.inspect(process) and things like Object.prototype.toString.call(process.env), so this patch changes the behaviour for the getter to just always return undefined.

/cc @cjihrig

1aa595e introduced a `throw` for accessing `Symbol` properties of
`process.env`. However, this breaks `util.inspect(process)` and
things like `Object.prototype.toString.call(process.env)`, so this
patch changes the behaviour for the getter to just always return
`undefined`.
@addaleax addaleax added c++ Issues and PRs that require attention from people who are familiar with C++. dont-land-on-v4.x process Issues and PRs related to the process subsystem. labels Nov 16, 2016
@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Nov 16, 2016
@@ -2681,6 +2681,9 @@ static void ProcessTitleSetter(Local<Name> property,
static void EnvGetter(Local<Name> property,
const PropertyCallbackInfo<Value>& info) {
Isolate* isolate = info.GetIsolate();
if (property->IsSymbol()) {
return info.GetReturnValue().SetUndefined();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling .SetUndefined() explicitly doesn't hurt but it's not strictly necessary as it's the default return value. We don't call it anywhere else.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bnoordhuis I think making the return value explicit is more readable here, that’s all. If you prefer, I have no problem dropping it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the C++ equivalent of function() { return undefined; }? I've no strong feelings, but explicit isn't necessarily more readable, IMHO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the C++ equivalent of function() { return undefined; }?

Yup.

I've no strong feelings, but explicit isn't necessarily more readable, IMHO.

I agree, but in this instance I think it makes sense.

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jasnell jasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label Nov 18, 2016
@jasnell
Copy link
Member

jasnell commented Nov 18, 2016

Marking as semver-major due to the change in error handling.

@addaleax
Copy link
Member Author

@jasnell This partially undoes a not-yet-released semver-major change, I’m not sure that qualifies as semver-major on its own?

CI: https://ci.nodejs.org/job/node-test-commit/6089/

@addaleax
Copy link
Member Author

Landed in 3295a7f, thanks for reviewing everyone!

@addaleax addaleax closed this Nov 20, 2016
addaleax added a commit that referenced this pull request Nov 20, 2016
1aa595e introduced a `throw` for accessing `Symbol` properties of
`process.env`. However, this breaks `util.inspect(process)` and
things like `Object.prototype.toString.call(process.env)`, so this
patch changes the behaviour for the getter to just always return
`undefined`.

Ref: #9446
Fixes: #9641
PR-URL: #9631
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@addaleax addaleax deleted the util-inspect-process-env branch November 20, 2016 00:58
@jasnell
Copy link
Member

jasnell commented Nov 20, 2016

It's a bit of a grey area

On Sat, Nov 19, 2016 at 4:05 PM Anna Henningsen notifications@github.com
wrote:

@jasnell https://github.com/jasnell This partially undoes a
not-yet-released semver-major change, I’m not sure that qualifies as
semver-major on its own?

CI: https://ci.nodejs.org/job/node-test-commit/6089/


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#9631 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAa2eYKDlWH8AgY0gpoQ5rtZ38ViTs_tks5q_47NgaJpZM4KzQBC
.

italoacasas pushed a commit to italoacasas/node that referenced this pull request Jan 18, 2017
1aa595e introduced a `throw` for accessing `Symbol` properties of
`process.env`. However, this breaks `util.inspect(process)` and
things like `Object.prototype.toString.call(process.env)`, so this
patch changes the behaviour for the getter to just always return
`undefined`.

Ref: nodejs#9446
Fixes: nodejs#9641
PR-URL: nodejs#9631
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@jasnell jasnell mentioned this pull request Apr 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. process Issues and PRs related to the process subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants