Uh oh!
There was an error while loading. Please reload this page.
src: add process.binding('config') - #6266
Conversation
Uh, that is not ok. We aren't just going to expose an alias on |
jasnell
commented
Apr 19, 2016
Doesn't really seem like an issue to me but very well. Made it internal. PTAL |
Fishrock123
commented
Apr 19, 2016
@jasnell Should this also contain a change changing our internals to use this? It's not very useful to land something that no-one uses. :) |
jasnell
commented
Apr 19, 2016
Currently in master we only use If/when this lands, I intend to backport it to resolve the existing regressions that have occurred in v5 and v4. |
| .replace(/'/g, '"'); | ||
| process.config = JSON.parse(config, function(key, value) { | ||
| process.config = exports.config = JSON.parse(config, (key, value) => { |
There was a problem hiding this comment.
This line doesn't make a copy, process.config and exports.config point to the same object.
There was a problem hiding this comment.
Yep. Modification is still possible. The problem we're having in userland is with code that does stuff like process.config = {}, essentially overwriting everything. The userland code that extends the object hasn't been a problem that I can determine. This is an attempt at doing the simplest thing first. If we need to lock it down more, then let's do so.
There was a problem hiding this comment.
If we want to be robust against users clobbering the runtime environment, then we shouldn't take half measures; either we guard against it or we don't.
jasnell
commented
Apr 19, 2016
The other obvious option here is to set a rule that we simply should not be depending on this in core code at all. If some bit of code needs to know if a config flag was set on compile time, then some other mechanism should be used to expose (perhaps an |
bnoordhuis
commented
Apr 19, 2016
That's sounds fine. As long as the net effect is the same. |
trevnorris
commented
Apr 19, 2016
Would it be considered a breaking change to make or read only? Native modules use |
jasnell
commented
Apr 19, 2016
There are a number of userland modules that either replace |
jasnell
commented
Apr 19, 2016
Ok, so looking it over I can see a couple of possible routes. Here's one that I just stepped through the implementation on:
Thoughts? Other solutions? |
bnoordhuis
commented
Apr 19, 2016
There's never been any stability guarantee for |
jasnell
commented
Apr 19, 2016
@bnoordhuis, @srl295, @trevnorris, @Fishrock123 ... PTAL. Reworked this completely to use the proposed |
vkurchatkin
commented
Apr 20, 2016
@jasnell why underscore? Binding is already private |
jasnell
commented
Apr 20, 2016
To ahem underscore the point? ;) Honestly it's just what I chose in the moment. You're right that it's redundant. |
6f62762 to
b9afcf3Comparejasnell
commented
Apr 20, 2016
@vkurchatkin ... updated to remove the underscore! |
There was a problem hiding this comment.
nit: this should go between buffer and constants
Fishrock123
commented
Apr 20, 2016
Can we put the place we are actually going to use this into this PR? This is kinda pointless without being coupled to it. :) |
jasnell
commented
Apr 20, 2016
@Fishrock123 ... that's a separate issue (#4253 (comment)) that makes much more sense keeping separated. Also, I'd prefer to keep this separate as I intend to backport it to v5 and v4 to address bugs there. |
PR-URL: nodejs#6266 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
It turns out that userland likes to override process.config with
their own stuff. If we want to be able to depend on it in any way,
we need our own internal mechanism.
This adds a new private process.binding('config') that is
intended to serve as a container for internal flags and compile
time configs that need to be passed on to the JS layer.
PR-URL: nodejs#6266
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>PR-URL: nodejs#6266 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: #6266 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
It turns out that userland likes to override process.config with
their own stuff. If we want to be able to depend on it in any way,
we need our own internal mechanism.
This adds a new private process.binding('config') that is
intended to serve as a container for internal flags and compile
time configs that need to be passed on to the JS layer.
PR-URL: #6266
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>PR-URL: #6266 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins
commented
Jun 30, 2016
@jasnell do we still want to backport this to v4.x? |
jasnell
commented
Jun 30, 2016
Oh right! I'll do that.
|
PR-URL: nodejs#6266 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
It turns out that userland likes to override process.config with
their own stuff. If we want to be able to depend on it in any way,
we need our own internal mechanism.
This adds a new private process.binding('config') that is
intended to serve as a container for internal flags and compile
time configs that need to be passed on to the JS layer.
PR-URL: nodejs#6266
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>PR-URL: #6266 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
It turns out that userland likes to override process.config with
their own stuff. If we want to be able to depend on it in any way,
we need our own internal mechanism.
This adds a new private process.binding('config') that is
intended to serve as a container for internal flags and compile
time configs that need to be passed on to the JS layer.
PR-URL: #6266
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>PR-URL: #6266 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
It turns out that userland likes to override process.config with
their own stuff. If we want to be able to depend on it in any way,
we need our own internal mechanism.
This adds a new private process.binding('config') that is
intended to serve as a container for internal flags and compile
time configs that need to be passed on to the JS layer.
PR-URL: #6266
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>PR-URL: #6266 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
It turns out that userland likes to override process.config with
their own stuff. If we want to be able to depend on it in any way,
we need our own internal mechanism.
This adds a new private process.binding('config') that is
intended to serve as a container for internal flags and compile
time configs that need to be passed on to the JS layer.
PR-URL: #6266
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>PR-URL: #6266 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
It turns out that userland likes to override process.config with
their own stuff. If we want to be able to depend on it in any way,
we need our own internal mechanism.
This adds a new private process.binding('config') that is
intended to serve as a container for internal flags and compile
time configs that need to be passed on to the JS layer.
PR-URL: #6266
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>PR-URL: #6266 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
It turns out that userland likes to override process.config with
their own stuff. If we want to be able to depend on it in any way,
we need our own internal mechanism.
This adds a new private process.binding('config') that is
intended to serve as a container for internal flags and compile
time configs that need to be passed on to the JS layer.
PR-URL: #6266
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Checklist
Affected core subsystem(s)
process
Description of change
It turns out that userland likes to override process.config with their own stuff. If we want to be able to depend on it in any way, we need our own internal reference. It's still not read-only but that should be ok.process.configcan and likely will be overwrittenprocess.binding('config')/cc @Fishrock123@srl295