summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2019-01-31report: fix typo in error messagecjihrig
PR-URL: https://github.com/nodejs/node/pull/25782 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-31http: make timeout event work with agent timeoutLuigi Pinca
The `'timeout'` event is currently not emitted on the `ClientRequest` instance when the socket timeout expires if only the `timeout` option of the agent is set. This happens because, under these circumstances, `listenSocketTimeout()` is not called. This commit fixes the issue by calling it also when only the agent `timeout` option is set. PR-URL: https://github.com/nodejs/node/pull/25488 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-30process: simplify report uncaught exception logiccjihrig
This commit combines two if statements into a single if statement. Another if statement is replaced with a ternary. PR-URL: https://github.com/nodejs/node/pull/25744 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-01-30lib: refactor ERR_SYNTHETICcjihrig
- Tidy up description in docs. - Remove a second definition in the docs. - Remove unused string input parameter. - Remove duplicate "JavaScript Callstack" in error messages. PR-URL: https://github.com/nodejs/node/pull/25749 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-01-30module: do not use `process.exit()`Anna Henningsen
Inside workers, using stdio is always asynchronous, so using `process.exit()` always interrupts sending of messages to the parent thread, including error messages presented over stdio. Do not use `process.exit()` and instead trigger a “real” uncaught exception. PR-URL: https://github.com/nodejs/node/pull/25769 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-30module: silence ModuleJob unhandled rejection warningsAnna Henningsen
This could otherwise print unhandled rejection warnings if the process does not exit immediately inside an earlier `.catch()` handler. PR-URL: https://github.com/nodejs/node/pull/25769 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-30worker: export workerData to ESM workersAnna Henningsen
Fixes: https://github.com/nodejs/node/issues/25765 PR-URL: https://github.com/nodejs/node/pull/25768 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-30worker: move worker thread setup code into the main scriptJoyee Cheung
This patch directly inlines `createMessageHandler()` and `createWorkerFatalExeception()` in the new `lib/internal/main/worker_thread.js` since the implementation of the two methods are related to the execution flow of workers. PR-URL: https://github.com/nodejs/node/pull/25667 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-01-30process: split execution into main scriptsJoyee Cheung
This patch splits the execution mode selection from the environment setup in `lib/internal/bootstrap/node.js`, and split the entry point of different execution mode into main scripts under `lib/internal/main`: - `check_syntax.js`: used when `-c`/`--check` which only checks the syntax of the input instead of executing it. - `eval_stdin.js`: used when `-e` is passed without value and stdin is not a TTY (e.g. something is piped). - `eval_string`: used when `-e` is passed along with a string argument - `inspect.js`: for `node inspect`/`node debug` - `print_bash_completion.js`: for `--completion-bash` - `print_help.js`: for `--help` - `prof_process.js`: for `--prof-process` - `repl.js`: for the REPL - `run_main_module.js`: used when a main module is passed - `run_third_party_main.js`: for the legacy `_third_party_main.js` support - `worker_thread.js`: for workers This makes the entry points easier to navigate and paves the way for customized v8 snapshots (that do not need to deserialize execution mode setup) and better embedder APIs. As an example, after this patch, for the most common case where Node.js executes a user module as an entry point, it essentially goes through: - `lib/internal/per_context.js` to setup the v8 Context (which is also run when setting up contexts for the `vm` module) - `lib/internal/bootstrap/loaders.js` to set up internal binding and builtin module loaders (that are separate from the loaders accessible in the user land). - `lib/internal/bootstrap/node.js`: to set up the rest of the environment, including various globals and the process object - `lib/internal/main/run_main_module.js`: which is selected from C++ to prepare execution of the user module. This patch also removes `NativeModuleLoader::CompileAndCall` and exposes `NativeModuleLoader::LookupAndCompile` directly so that we can handle syntax errors and runtime errors of bootstrap scripts differently. PR-URL: https://github.com/nodejs/node/pull/25667 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-01-29policy: ensure workers do not read fs for policyBradley Farias
This prevents a main thread from rewriting the policy file and loading a worker that has a different policy from the main thread. PR-URL: https://github.com/nodejs/node/pull/25710 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-01-28timers: truncate decimal valuesJeremiah Senkpiel
Reverts some timers behavior back to as it was before 2930bd1317d15d12738a4896c0a6c05700411b47 That commit introduced an unintended change which allowed non-integer timeouts to actually exist since the value is no longer converted to an integer via a TimeWrap handle directly. Even with the fix in e9de43549843da9f4f081cce917945878967df7 non-integer timeouts are still indeterministic, because libuv does not support them. This fixes the issue by emulating the old behavior: truncate the `_idleTimeout` before using it. See comments in https://github.com/nodejs/node/pull/24214 for more background on this. PR-URL: https://github.com/nodejs/node/pull/24819 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-29src: in-source comments and minor TLS cleanupsSam Roberts
Renamed some internal C++ methods and properties for consistency, and commented SSL I/O. - Rename waiting_new_session_ after is_waiting_new_session(), instead of using reverse naming (new_session_wait_), and change "waiting" to "awaiting". - Make TLSWrap::ClearIn() return void, the value is never used. - Fix a getTicketKeys() cut-n-paste error. Since it doesn't use the arguments, remove them from the js wrapper. - Remove call of setTicketKeys(getTicketKeys()), its a no-op. PR-URL: https://github.com/nodejs/node/pull/25713 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-01-28dns: use IDNA 2008 to encode non-ascii hostnamesBen Noordhuis
Before this commit, Node.js left it up to the system resolver or c-ares. Leaving it to the system resolver introduces platform differences because: * some support IDNA 2008 * some only IDNA 2003 (glibc until 2.28), and * some don't support IDNA at all (musl libc) c-ares doesn't support IDNA either although curl does, by virtue of linking against libidn2. Upgrading from libidn1 to libidn2 in order to get proper IDNA 2008 support was the fix for curl's CVE-2016-8625. libidn2 is not an option (incompatible license) but ICU has an IDNA API and we already use that in one place. For non-ICU builds, we fall back to the bundled punycode.js that also supports IDNA 2008. Fixes: https://github.com/nodejs-private/security/issues/97 Fixes: https://github.com/nodejs/node/issues/25558 PR-URL: https://github.com/nodejs/node/pull/25679 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
2019-01-27net,http2: merge setTimeout codeZYSzys
PR-URL: https://github.com/nodejs/node/pull/25084 Refs: https://github.com/nodejs/node/issues/19060 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-01-27assert: adjust loose assertionsRuben Bridgewater
This changes the loose deep equal comparison by using the same logic as done in the strict deep equal comparison besides comparing primitives loosely, not comparing symbol properties and not comparing the prototype. `assert.deepEqual` is still commenly used and this is likely the biggest pitfall. Most changes are only minor and won't have a big impact besides likely fixing user expectations. PR-URL: https://github.com/nodejs/node/pull/25008 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2019-01-25src: remove has_experimental_policy optionAnna Henningsen
This would be set when `--experimental-policy` was set, but since an empty string does not refer to a valid file, we can just check the value of `--experimental-policy` directly. PR-URL: https://github.com/nodejs/node/pull/25628 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2019-01-25lib: refactor policy code for readabilityAnna Henningsen
Simplify a few particularly quirky bits of code, and add whitespace for readability. PR-URL: https://github.com/nodejs/node/pull/25629 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2019-01-24report: remove `internalBinding('config').hasReport`Anna Henningsen
The `setup()` method is only called when the `--experimental-report` option is set. `getOptionValue()` returns `undefined` when the flag is not defined, so the extra check inside of `setup()` is redundant. PR-URL: https://github.com/nodejs/node/pull/25610 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-01-24crypto: add crypto modules to cannotUseCacheDaniel Bevenius
Currently, when configured --without-ssl there are two failures like the following: internal/util.js:101 throw new ERR_NO_CRYPTO(); ^ Error [ERR_NO_CRYPTO]: Node.js is not compiled with OpenSSL crypto support at assertCrypto (internal/util.js:101:11) at crypto.js:31:1 at NativeModule.compile (internal/bootstrap/loaders.js:316:5) at NativeModule.require (internal/bootstrap/loaders.js:219:7) at internal/policy/manifest.js:10:16 at NativeModule.compile (internal/bootstrap/loaders.js:316:5) at NativeModule.require (internal/bootstrap/loaders.js:219:7) at internal/process/policy.js:6:22 at NativeModule.compile (internal/bootstrap/loaders.js:316:5) at Function.NativeModule.require (internal/bootstrap/loaders.js:219:7) This commit adds policy/manifest and process/policy to cannotUseCache. PR-URL: https://github.com/nodejs/node/pull/25606 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-01-23child_process: truncate output when maxBuffer is exceededJeremiah Senkpiel
Preserves truncated output for `child_process.exec()` when `maxBuffer` is exceeded. This is particularly useful for commands which have indistinguishable error codes for what output they produce. PR-URL: https://github.com/nodejs/node/pull/24951 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-01-23process: fix call process.reallyExit, vs., bindingBenjamin Coe
Some user-land modules, e.g., nyc, mocha, currently rely on patching process.reallyExit. PR-URL: https://github.com/nodejs/node/pull/25655 Fixes: https://github.com/nodejs/node/issues/25650 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-01-23events: show inspected error in uncaught 'error' messageAnna Henningsen
If there is no handler for `.emit('error', value)` and `value` is not an `Error` object, we currently just call `.toString()` on it. Almost always, using `util.inspect()` provides better information for diagnostic purposes, so prefer to use that instead. Refs: https://github.com/nodejs/help/issues/1729 PR-URL: https://github.com/nodejs/node/pull/25621 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matheus Marchini <mat@mmarchini.me>
2019-01-23http2: allow fully synchronous `_final()`Anna Henningsen
HTTP/2 streams do not use the fact that the native `StreamBase::Shutdown()` is asynchronous by default and always finish synchronously. Adding a status code for this scenario allows skipping an expensive `MakeCallback()` C++/JS boundary crossing. PR-URL: https://github.com/nodejs/node/pull/25609 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-01-23console: refactor inspector console extension installationJoyee Cheung
- Instead of creating the console extensions eagerly during bootstrap and storing them on an object, wrap the code into a function to be called during `installAdditionalCommandLineAPI` only when the extensions are actually needed, which may not even happen if the user do not use the console in an inspector session, and does not need to happen during bootstrap unconditionally. - Simplify the console methods wrapping and move the `consoleFromVM` storage to `internal/util/inspector.js` PR-URL: https://github.com/nodejs/node/pull/25450 Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-01-23process: clarify the pre- and post-condition of esm setupJoyee Cheung
This patch: - Clarifies the dependency of the ESM loader initialization (`process.cwd()` and the value of `--loader`) in `node.js`. - Moves the initialization of the per-isolate `importModuleDynamically` and `initializeImportMetaObject` callbacks into `node.js` - Moves the initialization of the ESM loader into `prepareUserCodeExecution()` since it potentially involves execution of user code (similar to `--require` for CJS modules). PR-URL: https://github.com/nodejs/node/pull/25530 Reviewed-By: Gus Caplan <me@gus.host>
2019-01-22http: make ClientRequest#setTimeout() noop at endTim De Pauw
Originally discovered and resolved by @szmarczak. PR-URL: https://github.com/nodejs/node/pull/25536 Fixes: https://github.com/nodejs/node/issues/25499 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-01-20test: switch to native v8 coverageBenjamin Coe
PR-URL: https://github.com/nodejs/node/pull/25157 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-01-20http: reuse noop function in socketOnError()cjihrig
PR-URL: https://github.com/nodejs/node/pull/25566 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-01-20tls: make tls.connect() accept a timeout optionLuigi Pinca
If specified, and only when a socket is created internally, the option will make `socket.setTimeout()` to be called on the created socket with the given timeout. This is consistent with the `timeout` option of `net.connect()` and prevents the `timeout` option of the `https.Agent` from being ignored when a socket is created. PR-URL: https://github.com/nodejs/node/pull/25517 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-01-18crypto: fix key handle extractionTobias Nießen
PR-URL: https://github.com/nodejs/node/pull/25562 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-01-18util: fix iterable types with special prototypeRuben Bridgewater
The fallback should only be taken for a null prototype. If an iterable data type (e.g., Array) has a prototype without `Symbol.iterator`, just try the best to visualize it as object. PR-URL: https://github.com/nodejs/node/pull/25457 Fixes: https://github.com/nodejs/node/issues/25451 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-18test: add node-report testsLakshmiSwethaG
One test per each API, so that additional tests in future are modular. test/common/report.js contain common functions that tests leverage. PR-URL: https://github.com/nodejs/node/pull/22712 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <Michael_Dawson@ca.ibm.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2019-01-18src: merge into coreGireesh Punathil
Make node-report part of core runtime because: 1. When enabled, node-report significantly helps root cause various types of problems, including support issues sent to the various repos of the Node.js organization. 2. The requirement of explicitly adding the dependency to node-report in user applications often represents a blocker to adoption. Major deviation from the module version of the node-report is that the report is generated in JSON format, as opposed to human readable text. No new functionalities have been added, changes that are required for melding it as a built-in capability has been affected on the module version of node-report (https://github.com/nodejs/node-report) Co-authored-by: Bidisha Pyne <bidipyne@in.ibm.com> Co-authored-by: Howard Hellyer <hhellyer@uk.ibm.com> Co-authored-by: Jeremiah Senkpiel <fishrock123@rocketmail.com> Co-authored-by: Julian Alimin <dmastag@yahoo.com> Co-authored-by: Lakshmi Swetha Gopireddy <lakshmigopireddy@in.ibm.com> Co-authored-by: Manusaporn Treerungroj <m.treerungroj@gmail.com> Co-authored-by: Michael Dawson <michael_dawson@ca.ibm.com> Co-authored-by: Richard Chamberlain <richard_chamberlain@uk.ibm.com> Co-authored-by: Richard Lau <riclau@uk.ibm.com> Co-authored-by: Sam Roberts <vieuxtech@gmail.com> Co-authored-by: Vipin Menon <vipinmv1@in.ibm.com> PR-URL: https://github.com/nodejs/node/pull/22712 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <Michael_Dawson@ca.ibm.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2019-01-18worker: enable passing command line flagsYael Hermon
This PR adds the ability to provide Workers with their own execArgv flags in replacement of the main thread's execArgv. Only per-Isolate/per-Environment options are allowed. Per-Process options and V8 flags are not allowed. Passing an empty execArgv array will reset per-Isolate and per-Environment options of the Worker to their defaults. If execArgv option is not passed, the Worker will get the same flags as the main thread. Usage example: ``` const worker = new Worker(__filename, { execArgv: ['--trace-warnings'], }); ``` PR-URL: https://github.com/nodejs/node/pull/25467 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-01-17process: allow reading umask in workerscjihrig
Refs: https://github.com/nodejs/node/issues/25448 PR-URL: https://github.com/nodejs/node/pull/25526 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-01-17policy: manifest with subresource integrity checksBradley Farias
This enables code loaded via the module system to be checked for integrity to ensure the code loaded matches expectations. PR-URL: https://github.com/nodejs/node/pull/23834 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-01-16src: pass cli options to bootstrap/loaders.js lexicallyJoyee Cheung
Instead of using `internalBinding('config')` which should be used to carry information about build-time options, directly pass the run-time cli options into bootstrap/loaders.js lexically via function arguments. PR-URL: https://github.com/nodejs/node/pull/25463 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-01-16process: register the inspector async hooks in bootstrap/node.jsJoyee Cheung
So it's easier to tell the side effects of this setup. PR-URL: https://github.com/nodejs/node/pull/25443 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-01-16process: refactor coverage setup during bootstrapJoyee Cheung
- Renamed `internal/process/write-coverage.js` to `internal/coverage-gen/with_instrumentation.js`, `internal/process/coverage.js` to `internal/coverage-gen/with_profiler.js` to distinguish the two better and added comments. - Separate the coverage directory setup and the connection setup, moves the directory setup into `node.js` and closer to the exit hooks because that's where it's used. - Moves the `process.reallyExit` overwrite and `process.on('exit')` hooks setup into bootstrap/node.js for clarity, and move them to a later stage of bootstrap since they do not have to happen that early. PR-URL: https://github.com/nodejs/node/pull/25398 Reviewed-By: Ben Coe <bencoe@gmail.com>
2019-01-16os: add fallback for undefined CPUsMinwoo Jung
For an unsupported OS, a call to os.cpus() throws an error within os.cpus() itself where it tries to get the length of it. This fixes the issue by adding fallback for undefined CPUs. Fixes: https://github.com/nodejs/node/issues/25483 PR-URL: https://github.com/nodejs/node/pull/25493 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-01-16process: allow StartExecution() to take a main script IDJoyee Cheung
The idea is to allow the C++ layer to run arbitrary scripts as the main script. This paves the way for - cctest of the execution of Node.js instances - Earlier handling of per-process CLI options that affect execution modes (those usually do not make sense for the embedders). - Targets like mkcodecache or mksnapshot. Also moves the handling of `_third_party_main.js` into C++. PR-URL: https://github.com/nodejs/node/pull/25474 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2019-01-14util: fixes type in argument type validation errorAnkur Oberoi
PR-URL: https://github.com/nodejs/node/pull/25103 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-01-14os: improve networkInterfaces() performanceBrian White
PR-URL: https://github.com/nodejs/node/pull/25410 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-01-12src: simplify NativeModule caching and remove redundant dataJoyee Cheung
- Remove `NativeModule._source` - the compilation is now entirely done in C++ and `process.binding('natives')` is implemented directly in the binding loader so there is no need to store additional source code strings. - Instead of using an object as `NativeModule._cached` and insert into it after compilation of each native module, simply prebuild a JS map filled with all the native modules and infer the state of compilation through `mod.loading`/`mod.loaded`. - Rename `NativeModule.nonInternalExists` to `NativeModule.canBeRequiredByUsers` and precompute that property for all the native modules during bootstrap instead of branching in every require call during runtime. This also fixes the bug where `worker_threads` can be made available with `--expose-internals`. - Rename `NativeModule.requireForDeps` to `NativeModule.requireWithFallbackInDeps`. - Add a test to make sure we do not accidentally leak any module to the global namespace. PR-URL: https://github.com/nodejs/node/pull/25352 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-01-11util: remove eslint comments and rename variablesRuben Bridgewater
This should improve the readability of the code. PR-URL: https://github.com/nodejs/node/pull/25255 Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-11util: remove outdated commentRuben Bridgewater
This comment is not correct anymore. PR-URL: https://github.com/nodejs/node/pull/25255 Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-11util: simpler module namespace codeRuben Bridgewater
This removes a special casing for this data type in the main function. PR-URL: https://github.com/nodejs/node/pull/25255 Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-11util: code cleanupRuben Bridgewater
Remove some dead code plus some minor refactoring for readability. The constructor can not be an empty string anymore, so just remove that check. PR-URL: https://github.com/nodejs/node/pull/25255 Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-11util: switch recurseTimes counterRuben Bridgewater
This makes sure the counter goes up instead of going down. This allows to properly track the current inspection depth no matter what the `depth` option was set to. PR-URL: https://github.com/nodejs/node/pull/25255 Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-11url: return backslashes from fileURLToPath on winKevin Smith
PR-URL: https://github.com/nodejs/node/pull/25349 Fixes: https://github.com/nodejs/node/issues/25265 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com> Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>