summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2019-02-09crypto: include 'Buffer' in error output of Hash.update methodAmit Zur
Fixes: https://github.com/nodejs/node/issues/25487 PR-URL: https://github.com/nodejs/node/pull/25533 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2019-02-09http2: makes response.writeHead return the responseMark S. Everitt
Fixes: https://github.com/nodejs/node/issues/25935 PR-URL: https://github.com/nodejs/node/pull/25974 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-02-09http: makes response.writeHead return the responseMark S. Everitt
Fixes: https://github.com/nodejs/node/issues/25935 PR-URL: https://github.com/nodejs/node/pull/25974 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-02-08worker: use correct ctor for error serializationAnna Henningsen
When serializing errors, use the error constructor that is closest to the object itself in the prototype chain. The previous practice of walking downwards meant that `Error` would usually be the first constructor that is used, even when a more specific one would be available/appropriate, because it is the base class of the other common error types. PR-URL: https://github.com/nodejs/node/pull/25951 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-02-08perf_hooks: implement histogram based apiJames M Snell
Add a sampling-based event loop delay monitor. ```js const { monitorEventLoopDelay } = require('perf_hooks'); const h = monitorEventLoopDelay(); h.enable(); h.disable(); console.log(h.percentiles); console.log(h.min); console.log(h.max); console.log(h.mean); console.log(h.stddev); console.log(h.percentile(50)); ``` PR-URL: https://github.com/nodejs/node/pull/25378 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-02-08deps: update acorn to 6.0.7Michaël Zasso
acorn and acorn-walk are now published as two different packages. Put them both in subdirectories of `deps/acorn`. Adapt the REPL's recoverable error detection to use the new API for extending acorn parsers. PR-URL: https://github.com/nodejs/node/pull/25844 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-02-08lib: remove dollar symbol for private functionMaleDong
Just remove '$' because this isn't a programming language like Python. PR-URL: https://github.com/nodejs/node/pull/25590 Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-02-08lib: replace 'assert' with 'internal/assert' for many built-insRich Trott
Replace large 'assert' module with tiny 'internal/assert' module for many built-in uses. PR-URL: https://github.com/nodejs/node/pull/25956 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2019-02-08assert: create internal/assert micro-moduleRich Trott
For use in built-in modules that could benefit from `assert()` without having to load the entire module (unless an AssertionError actually occurs): lib/internal/assert.js. PR-URL: https://github.com/nodejs/node/pull/25956 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2019-02-08assert: refactor internal assert.jsRich Trott
Move lib/internal/assert.js to lib/internal/assert/assertion_error.js. This is in preparation for making lib/internal/assert.js a tiny module for use in Node.js built-ins so that we can use `assert()` without having to load the entire ~1200 line `assert` module. PR-URL: https://github.com/nodejs/node/pull/25956 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2019-02-08lib: use `internal/options` to query `--abort-on-uncaught-exception`Joyee Cheung
Instead of using `internalBinding('config').shouldAbortOnUncaughtException`. Also removes that property from the binding. PR-URL: https://github.com/nodejs/node/pull/25862 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-02-08process: move deprecation warning initialization into pre_execution.jsJoyee Cheung
Since this is only necessary when user code execution is expected. PR-URL: https://github.com/nodejs/node/pull/25825 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-08lib: move signal event handling into bootstrap/node.jsJoyee Cheung
Moves the `process.on()` and `promise.emit()` calls happened during bootstrap for signal events into `bootstrap/node.js` so it's easier to tell the side effects. Drive-by changes: - Moves the signal event re-arming to a point later during the bootstrap - as early as it were it's unlikely that there could be any existing signal events to re-arm for node-report. - Use a Map instead of an Object for signal wraps since it is used as a deletable dictionary anyway. PR-URL: https://github.com/nodejs/node/pull/25859 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-02-06perf_hooks: only enable GC tracking when it's requestedJoyee Cheung
Previously a GC prologue callback and a GC epilogue callback are always unconditionally enabled during bootstrap when the `performance` binding is loaded, even when the user does not use the performance timeline API to enable GC tracking. This patch makes the callback addition conditional and only enables them when the user explicitly requests `observer.observe(['gc'])` to avoid the overhead. PR-URL: https://github.com/nodejs/node/pull/25853 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-06http: remove redundant call to socket.setTimeout()Luigi Pinca
`Socket.prototype.setTimeout()` clears the previous timer before setting a new one. Refs: https://github.com/nodejs/node/pull/25748#discussion_r253393234 PR-URL: https://github.com/nodejs/node/pull/25928 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-06tls: null not valid as a renegotiate callbackSam Roberts
Allow undefined as a callback, but do not allow null. PR-URL: https://github.com/nodejs/node/pull/25929 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-06worker: remove undocumented .onclose propertyRich Trott
Remove setting of a 'close' event handler on MessagePort through the use of an `.onclose` property. We don't use this convention anywhere else in our codebase for 'close' events, this feature is undocumented, and we don't test it. PR-URL: https://github.com/nodejs/node/pull/25904 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
2019-02-06lib: fix a few minor issues flagged by lgtmRobin Neatherway
* Confusing (but correct) regex using `A-z` character range by accident * Add the status argument to afterShutdown PR-URL: https://github.com/nodejs/node/pull/25873 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
2019-02-06child_process: close pipe ends that are re-pipedGireesh Punathil
when t0 and t1 are spawned with t0's outputstream [1, 2] is piped into t1's input, a new pipe is created which uses a copy of the t0's fd. This leaves the original copy in Node parent, unattended. Net result is that when t0 produces data, it gets bifurcated into both the copies Detect the passed handle to be of 'wrap' type and close after the native spawn invocation by which time piping would have been over. Fixes: https://github.com/nodejs/node/issues/9413 Fixes: https://github.com/nodejs/node/issues/18016 PR-URL: https://github.com/nodejs/node/pull/21209 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-02-06repl: remove obsolete buffer clearingRuben Bridgewater
It is checked if an command buffer exists or not. This code branch can only be reached if none exist, so there's no need to clear that buffer again. PR-URL: https://github.com/nodejs/node/pull/25731 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-02-06repl: fix eval return valueRuben Bridgewater
In case no error has occurred during the evaluation of some code, `undefined` has been returned in some cases as error argument instead of `null`. This is fixed by this patch. PR-URL: https://github.com/nodejs/node/pull/25731 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-02-06repl: simplify and improve completionRuben Bridgewater
The completion lists used a hand crafted list of global entries that was redundant due to also using the actual global properties for tab completion. Those entries ended up in an separated completion group which did not seem useful. PR-URL: https://github.com/nodejs/node/pull/25731 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-02-05process: stub unsupported worker methodscjihrig
Some process methods are not supported in workers. This commit adds stubs that throw more informative errors. PR-URL: https://github.com/nodejs/node/pull/25587 Fixes: https://github.com/nodejs/node/issues/25448 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-05tls: in-line comments and other cleanupsSam Roberts
PR-URL: https://github.com/nodejs/node/pull/25861 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-02-05tls: don't shadow the tls global with a localSam Roberts
`tls` shadows the global `tls` require, and isn't indicative of the arument type. PR-URL: https://github.com/nodejs/node/pull/25861 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-02-05src: split ownsProcessState off isMainThreadAnna Henningsen
Embedders may want to control whether a Node.js instance controls the current process, similar to what we currently have with `Worker`s. Previously, the `isMainThread` flag had a bit of a double usage, both for indicating whether we are (not) running a Worker and whether we can modify per-process state. PR-URL: https://github.com/nodejs/node/pull/25881 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-04tls: check arg types of renegotiate()Sam Roberts
Don't throw on invalid property access if options is not provided, and ensure callback is a function. PR-URL: https://github.com/nodejs/node/pull/25876 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-02-03src,lib: remove dead `process.binding()` codeAnna Henningsen
There are no non-internal builtin modules left, so this should be safe to remove to a large degree. PR-URL: https://github.com/nodejs/node/pull/25829 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2019-02-03inspector,vm: remove --eval wrapperAnna Henningsen
Report the actual source code when running with `--eval` and `--inspect-brk`, by telling the vm module to break on the first line of the script being executed rather than wrapping the source code in a function. PR-URL: https://github.com/nodejs/node/pull/25832 Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-02-01tls: introduce client 'session' eventSam Roberts
OpenSSL has supported async notification of sessions and tickets since 1.1.0 using SSL_CTX_sess_set_new_cb(), for all versions of TLS. Using the async API is optional for TLS1.2 and below, but for TLS1.3 it will be mandatory. Future-proof applications should start to use async notification immediately. In the future, for TLS1.3, applications that don't use the async API will silently, but gracefully, fail to resume sessions and instead do a full handshake. See: https://wiki.openssl.org/index.php/TLS1.3#Sessions PR-URL: https://github.com/nodejs/node/pull/25831 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2019-02-02process: move DEP0062 (node --debug) to end-of-lifeJoyee Cheung
This has already been practically end-of-life since `node --debug` alone would exit the process. This patch drops support of `node --inspect --debug-brk` as well. `node --inspect --debug-brk` has been deprecated since v8, it has been maintained so that vendors can target Node.js v6 and above without detecting versions. The support of `--inspect`, which starts from v6, will reach end-of-life in April 2019, it should be safe to drop the support of `--inspect --debug-brk` altogether in v12. Also removes `process._deprecatedDebugBrk` PR-URL: https://github.com/nodejs/node/pull/25828 Refs: https://github.com/nodejs/node/pull/12949 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-02-02process: exit on --debug and --debug-brk after option parsingJoyee Cheung
Moves the exit of `--debug` and `--debug-brk` earlier, that is, after the option parsing is done in the C++ land. Also removes `process._invalidDebug`. PR-URL: https://github.com/nodejs/node/pull/25828 Refs: https://github.com/nodejs/node/pull/12949 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-02-02process: move process mutation into bootstrap/node.jsJoyee Cheung
This patch moves the part in the report initialization that mutates the process object into bootstrap/node.js so it's easier to tell the side effect of the initialization on the global state during bootstrap. PR-URL: https://github.com/nodejs/node/pull/25821 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-02-02process: expose process.features.inspectorJoyee Cheung
Instead of using process.config.variables.v8_enable_inspector to detect whether inspector is enabled in the build. PR-URL: https://github.com/nodejs/node/pull/25819 Refs: https://github.com/nodejs/node/issues/25343 Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-02-02lib: save primordials during bootstrap and use it in builtinsJoyee Cheung
This patches changes the `safe_globals` internal module into a script that gets run during bootstrap and saves JavaScript builtins (primordials) into an object that is available for all other builtin modules to access lexically later. PR-URL: https://github.com/nodejs/node/pull/25816 Refs: https://github.com/nodejs/node/issues/18795 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host>
2019-02-01worker: refactor thread id managementAnna Henningsen
- Assign thread IDs to `Environment` instances, rather than Workers. This is more embedder-friendly than the current system, in which all “main threads” (if there are multiple ones) would get the id `0`. - Because that means that `isMainThread === (threadId === 0)` no longer holds, refactor `isMainThread` into a separate entity. Implement it in a way that allows for future extensibility, because we use `isMainThread` in multiple different ways (determining whether there is a parent thread; determining whether the current thread has control of the current process; etc.). PR-URL: https://github.com/nodejs/node/pull/25796 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
2019-02-01http: return HTTP 431 on HPE_HEADER_OVERFLOW errorAlbert Still
Instead of returning a generic 400 response when the max header size is reached, return a 431 Request Header Fields Too Large. This is a semver-major because it changes the HTTP status code for requests that trigger the header overflow error. PR-URL: https://github.com/nodejs/node/pull/25605 Fixes: https://github.com/nodejs/node/issues/25528 Refs: https://tools.ietf.org/html/rfc6585#section-5 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
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>