-
Notifications
You must be signed in to change notification settings - Fork 30k
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
lib: explicitly initialize debuglog during bootstrap #26468
Conversation
So these can be required without requiring the whole `util.js`.
This patch splits the implementation of util.debuglog into a separate file and explicitly initialize it during pre-execution since the initialization depends on environment variables. Also delays the call to `debuglog` in modules that are loaded during bootstrap to make sure we only access the environment variable during pre-execution.
Landed in f617a73...b05fd4b |
So these can be required without requiring the whole `util.js`. PR-URL: nodejs#26468 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: nodejs#26468 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
This patch splits the implementation of util.debuglog into a separate file and explicitly initialize it during pre-execution since the initialization depends on environment variables. Also delays the call to `debuglog` in modules that are loaded during bootstrap to make sure we only access the environment variable during pre-execution. PR-URL: nodejs#26468 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
It looks like this may have broken our downstream modules fork More to come as I dig in and figure out exactly what is going on |
@MylesBorins My guess is there's something in the fork that loads // Don't do this in the top scope if it's loaded during bootstrap
const debug = require('util').debuglog('stream');
// Do this
let debuglog;
function debug(...args) {
if (!debuglog) {
debuglog = require('internal/util/debuglog').debuglog('stream');
}
debuglog(...args);
} |
thanks @joyeecheung. it looks like the file being required uses the above pattern... and I had a bit of an issue tracking down where the call to debug was happening in the wrong order. I opted instead to lazyload the instantiation of the CJSLoader see nodejs/ecmascript-modules@02bcd09 for attempted fix. Have a feeling this requires more attention, but appears good enough to move things forward for now |
This does land land cleanly on v11.x. It relies on #26466. As soon as that is backported, this should also land cleanly. |
So these can be required without requiring the whole `util.js`. PR-URL: nodejs#26468 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: nodejs#26468 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
This patch splits the implementation of util.debuglog into a separate file and explicitly initialize it during pre-execution since the initialization depends on environment variables. Also delays the call to `debuglog` in modules that are loaded during bootstrap to make sure we only access the environment variable during pre-execution. PR-URL: nodejs#26468 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
lib: move format and formatWithOptions into internal/util/inspect.js
So these can be required without requiring the whole
util.js
.process: call prepareMainThreadExecution in all main thread scripts
lib: explicitly initialize debuglog during bootstrap
This patch splits the implementation of util.debuglog into a
separate file and explicitly initialize it during pre-execution
since the initialization depends on environment variables.
Also delays the call to
debuglog
in modules that are loaded duringbootstrap to make sure we only access the environment variable
during pre-execution.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes