| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
It would be nice to move that condition up in the former if.
Sorry, something went wrong.
There was a problem hiding this comment.
Sounds good, I'll move it. Thanks
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
I think the name is actually process.config.variables.v8_enable_inspector?
Sorry, something went wrong.
There was a problem hiding this comment.
You are right, can't believe I missed that. 😞 Will update now. Thanks again!
Sorry, something went wrong.
|
You asked for the reason - If I am correct NativeModule.require('module') would have to be called first and that is not the case anymore. |
Sorry, something went wrong.
Thanks! Should we then perhaps do something like the following to still allow for the eager instantiation to happen: if (browserGlobals) {
if (!process.config.variables.v8_enable_inspector) {
NativeModule.require('module');
}
// Instantiate eagerly in case the first call is under stack overflow
// conditions where instantiation doesn't work.
const console = global.console;
console.assert;
console.clear;
console.count;
console.countReset;
console.dir;
console.error;
console.log;
console.time;
console.timeEnd;
console.trace;
console.warn;
} |
Sorry, something went wrong.
|
I would say let us wait for #15111. It should actually also solve the issue here and allow the eager instantiation. I do like the variable part a lot though and I guess it makes sense to switch the inspector check in the mentioned PR to this check instead. |
Sorry, something went wrong.
|
@danbev the mentioned PR just landed. I guess the issue itself should already be fixed but right now the inspector is always "loaded" and it is checked if it actually returns anything or not. Therefore it would still be nice to use process.config.variables.v8_enable_inspector instead. I did not add that to my PR as I forgot about that. |
Sorry, something went wrong.
|
@BridgeAR Sorry about the late reply (was at a f2f last week and had limited time). I'll take another look into this issue now. Thanks |
Sorry, something went wrong.
|
Rebased and updated CI: https://ci.nodejs.org/job/node-test-pull-request/10249/ |
Sorry, something went wrong.
There was a problem hiding this comment.
Depending on process.config is dangerous because there are userland modules that completely replace it. During bootstrap it should be safe but problems still could come up.
Sorry, something went wrong.
There was a problem hiding this comment.
If it ever becomes an issue, we could cache it before user code runs.
Sorry, something went wrong.
There was a problem hiding this comment.
Or use process.binding('config') as a stable alternative.
Sorry, something went wrong.
There was a problem hiding this comment.
@jasnell @cjihrig Thanks, I had not thought about that being an issue and I'm trying to understand how this might happen.
Using process.binding('config') will give access to the builtin module config, but as far as I can tell the information from config.gypi is provided as a native module (via node_js2c). The process object is then configured with that information in setupConfig which is called by node_bootstrap.js start function.
setupConfig deletes the config from the _source and then sets these properties on the process object. Since it deletes the _source this function cannot be called multiple times, for example if it did not we could have done the same thing again.
What I'm having some difficulties understand is that how could a userland module be able to replace this at this stage. Would someone be able to shed some light on this?
Sorry, something went wrong.
There was a problem hiding this comment.
Userland code might not be able to replace process.config by this stage, I haven't tested it. What I do know is that we've had issues depending on process.config in later stages elsewhere in the code and we if we are going to use it here then we need to be certain that it won't be a problem. If there is no userland code that can be run before bootstrap gets to this point, then it should be ok.
Sorry, something went wrong.
There was a problem hiding this comment.
This is still very early in the bootstrap process and I do not think it is possible to change it at that stage. To be on the safe side we could just add a test for it though.
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
I am not sure if this is a appropriate test.
I would have expected the v8_enable_inspector variable to be set to something falsy because we test it to be truthy and afterwards to check if the inspector is set up nevertheless.
Another approach would be to test that inspector is set without any variable manipulation. That should already verify that manipulating it has no impact on this anymore.
Sorry, something went wrong.
There was a problem hiding this comment.
@BridgeAR Thanks, I've updated the test. When going through the code I looks like any user land code will be call by Module.runMain, at which point the checking of process.config.variables.v8_enable_inspector done by bootstrap_node.js has already been performed. This also holds true for any preloaded modules. So as far as I can tell the check should be safe unless there are other ways this could happen that I've not taken into account.
Sorry, something went wrong.
|
@BridgeAR Would you mind taking another look at this now and see what you thing? Thanks |
Sorry, something went wrong.
There was a problem hiding this comment.
How do we know here that the inspector is indeed set up properly (I would have expected to test for inspector specific functions or similar)? That is the most important part out of my perspective. As soon as we know that the inspector is set up, we do not even have to manipulate the variable anymore, because it would not have any effect afterwards.
Sorry, something went wrong.
There was a problem hiding this comment.
@BridgeAR Thanks for the feedback. I'm not working for a few days but will take another look at this next week.
Sorry, something went wrong.
|
Thank you for adding the test, but I'm not quite sure it's enough. The earliest user code that can run would be a preload module using -r. The test could likely be improved by having it run with a preload module that sets process.config = {} then checking that the inspector code still works as required. |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
Still LGTM.
Sorry, something went wrong.
Currently the inspector module is always loaded and if it does not return anything the inspector console setup is skipped. This commit uses the process.config.variables.v8_enable_inspector variable to only load the inspector module if it is enabled.
Sorry, something went wrong.
Currently the inspector module is always loaded and if it does not return anything the inspector console setup is skipped. This commit uses the process.config.variables.v8_enable_inspector variable to only load the inspector module if it is enabled. PR-URL: #15008 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
Currently the inspector module is always loaded and if it does not return anything the inspector console setup is skipped. This commit uses the process.config.variables.v8_enable_inspector variable to only load the inspector module if it is enabled. PR-URL: #15008 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
Currently the inspector module is always loaded and if it does not return anything the inspector console setup is skipped. This commit uses the process.config.variables.v8_enable_inspector variable to only load the inspector module if it is enabled. PR-URL: #15008 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
| Back | FazBrowse Home | New Git URL |
Currently the inspector module is always loaded and if it does not
return anything the inspector console setup is skipped.
This commit uses the process.config.variables.v8_enable_inspector
variable to only load the inspector module if it is enabled.
Checklist
Affected core subsystem(s)
lib