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: use option parser for expose_internals #12245

Merged
merged 2 commits into from Apr 13, 2017

Conversation

@sam-github
Copy link
Member

commented Apr 5, 2017

bootstrap_node.js was directly parsing process.execArgv to see if
internals should be exposed, even though the argv was already parsed by
node. This is unusual and unnecessary, change it to set the option value
from the parser onto the process object, as is done for the other CLI
options.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows [commit guidelines][]
Affected core subsystem(s)

src

@sam-github

This comment has been minimized.

Copy link
Member Author

commented Apr 5, 2017

@sam-github sam-github referenced this pull request Apr 5, 2017
4 of 4 tasks complete

@mscdex mscdex added the process label Apr 5, 2017

src/node.cc Outdated
@@ -3279,6 +3280,7 @@ void SetupProcessObject(Environment* env,
READONLY_PROPERTY(process, "_forceRepl", True(env->isolate()));
}

// -r,--require

This comment has been minimized.

Copy link
@richardlau

richardlau Apr 5, 2017

Member

Actually can you add a space here after the comma to be consistent with the other existing comments?

This comment has been minimized.

Copy link
@sam-github

sam-github Apr 6, 2017

Author Member

done, thanks (also, fixed up the existing comment which did not use a space)

src/node.cc Outdated
@@ -3334,6 +3338,11 @@ void SetupProcessObject(Environment* env,
READONLY_PROPERTY(process, "_debugWaitConnect", True(env->isolate()));
}

// --expose_internals,--expose-internals

This comment has been minimized.

Copy link
@richardlau
@jasnell
Copy link
Member

left a comment

In addition to the other issue mentioned, this should have a minimal test to verify that the property is set.

src/node.cc Outdated
// --expose_internals,--expose-internals
if (expose_internals) {
READONLY_PROPERTY(process, "_exposeInternals", True(env->isolate()));
}

This comment has been minimized.

Copy link
@jasnell

jasnell Apr 6, 2017

Member

Would prefer to use process.binding('config') for this rather than adding a new _-prefixed property off process

This comment has been minimized.

Copy link
@sam-github

sam-github Apr 6, 2017

Author Member

PTAL, there is no new property created off of process (its deleted later). I'll add an assertion of that fact to the existing test.

@sam-github sam-github force-pushed the use-expose-internals branch to 8675a23 Apr 6, 2017

src/node.cc Outdated
@@ -3334,6 +3338,13 @@ void SetupProcessObject(Environment* env,
READONLY_PROPERTY(process, "_debugWaitConnect", True(env->isolate()));
}

// --expose_internals, --expose-internals
// Note that this is not exposed as a process property, it is deleted when

This comment has been minimized.

Copy link
@sam-github

sam-github Apr 6, 2017

Author Member

@jasnell PTAL

This comment has been minimized.

Copy link
@Fishrock123

Fishrock123 Apr 7, 2017

Member

not sure the note is necessary, many setup properties do this

This comment has been minimized.

Copy link
@sam-github

sam-github Apr 7, 2017

Author Member

I didn't think it was necessary either, but it confused @jasnell - James, what do you think?

This comment has been minimized.

Copy link
@jasnell

jasnell Apr 10, 2017

Member

I want confused. I'm not fond of this pattern. Exposing via process.binding('config') is preferable to me.

@@ -5,3 +5,4 @@ require('../common');
const assert = require('assert');

assert.strictEqual(typeof require('internal/freelist').FreeList, 'function');
assert(!('_exposeInternals' in process), 'no process property is leaked');

This comment has been minimized.

Copy link
@sam-github

sam-github Apr 6, 2017

Author Member

@jasnell PTAL, I deliberately am making no change to the process properties (for cleanliness, and because it may potentically be backwards incompat, and also because its unnecessary, we can find if internal modules were exposed pretty easily by just trying to require one and seeing what happens, which is unusual to want to know, but possible).

This comment has been minimized.

Copy link
@Fishrock123

Fishrock123 Apr 7, 2017

Member

see

node/src/node.cc

Lines 1219 to 1221 in 8460284

env->process_object()->Delete(
env->context(),
FIXED_ONE_BYTE_STRING(args.GetIsolate(), "_setupPromises")).FromJust();
, this is already common practice, just usually from C++.

@cjihrig
cjihrig approved these changes Apr 9, 2017
@addaleax

This comment has been minimized.

Copy link
Member

commented Apr 10, 2017

@sam-github This might also need a rebase after landing #12241.
@jasnell Care to take another look? I think everything here has been addressed/answered.

@jasnell
Copy link
Member

left a comment

@addaleax I'd still prefer the process.binding('config') change to be honest.

@sam-github

This comment has been minimized.

Copy link
Member Author

commented Apr 10, 2017

@jasnell what change? You saw the property is never visible, and unit test to that effect? You want the property put somewhere else for its brief lifetime?

@sam-github sam-github force-pushed the use-expose-internals branch from 4e22b98 Apr 10, 2017

@sam-github

This comment has been minimized.

Copy link
Member Author

commented Apr 10, 2017

@jasnell I somehow missed your earlier comment, sorry.

You actually want this exposed as a new config property? I don't think I'm on-board for that. I'm trying to factor out an oddity where process.argv is re-parsed after it was already parsed, which strikes me as undesireable, not add new APIs that haven't been requested.

process.config in particular contains variables set by ./configure at this moment, it doesn't seem like the place to start adding command line arg flags. Maybe a process.options that contains the values of all the CLI options and flags would be an interesting feature, though I haven't seen that requested as a feature.

@sam-github sam-github force-pushed the use-expose-internals branch to 8b07404 Apr 10, 2017

@jasnell

This comment has been minimized.

Copy link
Member

commented Apr 11, 2017

No, not process.config, process.binding('config')... look at node_config.cc. It is an internal only mechanism for exposing configuration flags so that we can avoid hanging things off process and deleting them later. It was introduced specifically because process.config is unreliable and adding things to process is messy.

@sam-github

This comment has been minimized.

Copy link
Member Author

commented Apr 11, 2017

OK, I'll go look

@sam-github sam-github force-pushed the use-expose-internals branch from 88ca10f to d746bca Apr 11, 2017

@sam-github sam-github force-pushed the use-expose-internals branch from d746bca to 1b24364 Apr 12, 2017

@sam-github

This comment has been minimized.

Copy link
Member Author

commented Apr 12, 2017

sam-github added 2 commits Apr 5, 2017
src: supply missing comments for CLI options
A few of the CLI option values exposed as properties on the process
object were missing a comment, fix this.

PR-URL: #12245
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
src: use option parser for expose_internals
bootstrap_node.js was directly parsing process.execArgv to see if
internals should be exposed, even though the argv was already parsed by
node. This is unusual and unnecessary, change it to set the option value
from the parser onto the config binding.

PR-URL: #12245
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>

@sam-github sam-github force-pushed the use-expose-internals branch from 1b24364 to 8086cb6 Apr 13, 2017

@sam-github sam-github merged commit 8086cb6 into master Apr 13, 2017

@sam-github sam-github deleted the use-expose-internals branch Apr 13, 2017

@jasnell jasnell referenced this pull request May 11, 2017
@gibfahn gibfahn referenced this pull request Jun 15, 2017
2 of 3 tasks complete
@gibfahn

This comment has been minimized.

Copy link
Member

commented Jun 18, 2017

@sam-github when you merge multiple commits, could you still comment with Landed in HASH1 HASH2 as per the Collaborator Guide?

@gibfahn

This comment has been minimized.

Copy link
Member

commented Jun 18, 2017

Should this be backported to v6.x-staging? If yes please follow the guide and raise a backport PR, if no let me know or add the dont-land-on label.

sam-github added a commit to sam-github/node that referenced this pull request Jul 25, 2017
src: supply missing comments for CLI options
A few of the CLI option values exposed as properties on the process
object were missing a comment, fix this.

PR-URL: nodejs#12245
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
sam-github added a commit to sam-github/node that referenced this pull request Jul 25, 2017
src: use option parser for expose_internals
bootstrap_node.js was directly parsing process.execArgv to see if
internals should be exposed, even though the argv was already parsed by
node. This is unusual and unnecessary, change it to set the option value
from the parser onto the config binding.

PR-URL: nodejs#12245
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@sam-github

This comment has been minimized.

Copy link
Member Author

commented Jul 25, 2017

backported: #14483

MylesBorins added a commit that referenced this pull request Aug 14, 2017
src: supply missing comments for CLI options
A few of the CLI option values exposed as properties on the process
object were missing a comment, fix this.

PR-URL: #12245
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MylesBorins added a commit that referenced this pull request Aug 14, 2017
src: use option parser for expose_internals
bootstrap_node.js was directly parsing process.execArgv to see if
internals should be exposed, even though the argv was already parsed by
node. This is unusual and unnecessary, change it to set the option value
from the parser onto the config binding.

PR-URL: #12245
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MylesBorins added a commit that referenced this pull request Aug 14, 2017
src: supply missing comments for CLI options
A few of the CLI option values exposed as properties on the process
object were missing a comment, fix this.

Backport-PR-URL: #14483
PR-URL: #12245
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MylesBorins added a commit that referenced this pull request Aug 14, 2017
src: use option parser for expose_internals
bootstrap_node.js was directly parsing process.execArgv to see if
internals should be exposed, even though the argv was already parsed by
node. This is unusual and unnecessary, change it to set the option value
from the parser onto the config binding.

Backport-PR-URL: #14483
PR-URL: #12245
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MylesBorins added a commit that referenced this pull request Aug 14, 2017
src: supply missing comments for CLI options
A few of the CLI option values exposed as properties on the process
object were missing a comment, fix this.

Backport-PR-URL: #14483
PR-URL: #12245
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MylesBorins added a commit that referenced this pull request Aug 14, 2017
src: use option parser for expose_internals
bootstrap_node.js was directly parsing process.execArgv to see if
internals should be exposed, even though the argv was already parsed by
node. This is unusual and unnecessary, change it to set the option value
from the parser onto the config binding.

Backport-PR-URL: #14483
PR-URL: #12245
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MylesBorins added a commit that referenced this pull request Aug 16, 2017
src: supply missing comments for CLI options
A few of the CLI option values exposed as properties on the process
object were missing a comment, fix this.

Backport-PR-URL: #14483
PR-URL: #12245
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
MylesBorins added a commit that referenced this pull request Aug 16, 2017
src: use option parser for expose_internals
bootstrap_node.js was directly parsing process.execArgv to see if
internals should be exposed, even though the argv was already parsed by
node. This is unusual and unnecessary, change it to set the option value
from the parser onto the config binding.

Backport-PR-URL: #14483
PR-URL: #12245
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@MylesBorins MylesBorins referenced this pull request Aug 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
10 participants
You can’t perform that action at this time.