0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
Commit Graph

1579 Commits

Author SHA1 Message Date
cjihrig
f9cd5e3094
doc,lib,test: rename node-report to report
This commit completes the renaming of node-report to report
in order to better differentiate core's reporting from the
node-report npm module.

PR-URL: https://github.com/nodejs/node/pull/26371
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-02 21:17:33 -05:00
Tobias Nießen
b8018f407b
crypto: move DEP0113 to End-of-Life
PR-URL: https://github.com/nodejs/node/pull/26249
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-03-02 10:58:12 +01:00
Thomas
e9ed6b988f
console: prevent constructing console methods
Ref: https://github.com/nodejs/node/issues/25987

PR-URL: https://github.com/nodejs/node/pull/26096
Refs: https://github.com/nodejs/node/issues/25987
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
2019-03-02 00:07:53 +01:00
Ruben Bridgewater
410eb97bce
module: fix stat cache
The current caching logic broke by [0] because it used destructuring
on the module arguments. Since the exported property is a primitive
counting it up or down would not have any effect anymore in the module
that required that property.

The original implementation would cache all stat calls caused during
bootstrap. Afterwards it would clear the cache and lazy require calls
during runtime would create a new cascading cache for the then
loaded modules and clear the cache again.
This behavior is now restored. This is difficult to test without
exposing a lot of information and therfore the existing tests have
been removed (as they could not detect the issue).

With the broken implementation it caused each module compilation to
reset the cache and therefore minimizing the effect drastically.

[0] https://github.com/nodejs/node/pull/19177

PR-URL: https://github.com/nodejs/node/pull/26266
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-01 12:27:15 +01:00
Ruben Bridgewater
3fce5cf439
module: simpler shebang function
This simplifies the shebang function significantly. Before, it was
optimized for two characters input. Any module actually parsed should
however have more characters than just the shebang.
The performance stays the same as before.

PR-URL: https://github.com/nodejs/node/pull/26266
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-01 12:27:14 +01:00
Ruben Bridgewater
8bb30926fd
util: group array elements together
When using `util.inspect()` with `compact` mode set to a number, all
array entries exceeding 6 are going to be grouped together into
logical parts.

PR-URL: https://github.com/nodejs/node/pull/26269
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-03-01 00:04:16 +01:00
Ruben Bridgewater
4db10ed9ad
util: add compact depth mode
This overloads the `compact` option from `util.inspect()`. If it's
set to a number, it is going to align all most inner entries on the
same lign if they adhere to the following:

* The entries do not exceed the `breakLength` options value.
* The entry is one of the local most inner levels up the the one
  provided in `compact`.

PR-URL: https://github.com/nodejs/node/pull/26269
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-03-01 00:04:15 +01:00
Ruben Bridgewater
a32cbe1597
util: fix proxy inspection
This prevents any proxy traps from being called while inspecting
proxy objects. That guarantees a side-effect free way of inspecting
proxies.

PR-URL: https://github.com/nodejs/node/pull/26241
Fixes: https://github.com/nodejs/node/issues/10731
Fixes: https://github.com/nodejs/node/issues/26231
Refs: https://github.com/nodejs/node/issues/25212
Refs: https://github.com/nodejs/node/issues/24765
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-02-28 21:26:49 +01:00
Ruben Bridgewater
9edce1e12a
benchmark,doc,lib,test: capitalize comments
This updates a lot of comments.

PR-URL: https://github.com/nodejs/node/pull/26223
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
2019-02-28 18:31:10 +01:00
Ruben Bridgewater
7b674697d8
util: prevent leaking internal properties
This prevents leaking of the internal `inspect()` properties when
using a custom inspect function.

It also aligns the indentation to the way it was in v8.0.0 since
that changed unintentionally. All strings returned by the custom
inspect function will now be indented appropriately to the current
depth.

PR-URL: https://github.com/nodejs/node/pull/24971
Refs: https://github.com/nodejs/node/issues/24765
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-02-28 17:49:13 +01:00
Ruben Bridgewater
be78266fb3
lib: don't use util.inspect() internals
This makes sure the internal `stylize` function is not used to render
anything and instead just uses the regular inspect function in case
of reaching the maximum depth level.

PR-URL: https://github.com/nodejs/node/pull/24971
Refs: https://github.com/nodejs/node/issues/24765
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-02-28 17:49:10 +01:00
Ruben Bridgewater
6c52ef9825
util: mark iterator entries as such
It is possible to distinguish the entries iterator from others.
Expose that information to the users as well and improve the
Symbol.toStringTag handling by adding a special tag instead of
replacing the existent information.

PR-URL: https://github.com/nodejs/node/pull/26222
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2019-02-28 17:47:09 +01:00
cjihrig
fe8c1f69f2
report: refactor argument validation
PR-URL: https://github.com/nodejs/node/pull/26276
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-26 18:05:30 -05:00
cjihrig
d64aea0599
report: refactor triggerReport()
This commit fixes the triggerReport() argument validation. The
existing test is also updated, as it was not passing the Error
object to triggerReport().

PR-URL: https://github.com/nodejs/node/pull/26268
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-26 17:04:56 -05:00
cjihrig
d7a3c3cecc
errors: add ERR_INSPECTOR_COMMAND error
This error is used to propagate errors returned from the
inspector module's command system.

PR-URL: https://github.com/nodejs/node/pull/26255
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-02-26 16:44:34 -05:00
cjihrig
4900863043
url: handle quasi-WHATWG URLs in urlToOptions()
PR-URL: https://github.com/nodejs/node/pull/26226
Refs: https://github.com/nodejs/node/issues/26198
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-02-26 16:04:03 -05:00
Joyee Cheung
bba27a11c5
process: use common operations to define browser globals
Extracts:

- `exposeNamespace`: https://heycam.github.io/webidl/#es-namespaces
- `exposeInterface`: https://heycam.github.io/webidl/#es-interfaces
- `defineOperation`: https://heycam.github.io/webidl/#define-the-operations

into functions to define browser globals.

PR-URL: https://github.com/nodejs/node/pull/26230
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-02-25 16:40:45 +08:00
Rich Trott
79a3348d14 worker: serialize errors if stack getter throws
Current code that is intended to handle the stack getter throwing is
untested. Add a test and adjust code to function as expected.

Co-authored-by: Anna Henningsen <anna@addaleax.net>
PR-URL: https://github.com/nodejs/node/pull/26145
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-02-24 21:27:29 -08:00
Joyee Cheung
b0869c64d1
process: move initialization of node-report into pre_execution.js
- Splits signal handler setup code into two functions: one sets up
  `process.on('SIGNAL_NAME')`, another takes care of the signal
  triggers of node-report. Both should only happen on the main thread.
  The latter needs to happen after the node-report configurations
  are read into the process.
- Move the initialization of node-report into pre_execution.js
  because it depends on CLI/environment settings.

PR-URL: https://github.com/nodejs/node/pull/26227
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-02-24 23:41:27 +01:00
Joyee Cheung
34470b0524
process: setup signal handler in prepareMainThreadExecution
Because this is only necessary in the main thread.
Also removes the rearming of signal events since no
signal event handlers should be created during the execution
of node.js now that we've made the creation of stdout and stderr
streams lazy - this has been demonstrated in the test coverage.

PR-URL: https://github.com/nodejs/node/pull/26227
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-02-24 23:41:27 +01:00
cjihrig
a1d05e49fe
timers: support name in validateTimerDuration()
Allow passing a name to validateTimerDuration() so that error
messages can reflect the name of the thing being validated.

PR-URL: https://github.com/nodejs/node/pull/26215
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-22 13:39:21 -05:00
Joyee Cheung
c435f069eb
process: simplify the setup of async hooks trace events
- Remove `trace_category_state` from `Environment` - since this is
  only accessed in the bootstrap process and later in the
  trace category update handler, we could just pass the initial
  values into JS land via the trace_events binding, and pass
  the dynamic values directly to the handler later, instead of
  accessing them out-of-band via the AliasedBuffer.
- Instead of creating the hooks directly in
  `trace_events_async_hooks.js`, export the hook factory and
  create the hooks in trace category state toggle.

PR-URL: https://github.com/nodejs/node/pull/26062
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-21 10:47:28 +08:00
Joyee Cheung
435eea6400
src: move async hooks trace events setup to pre_execution.js
Reasons:

- Moves more environment-dependent setup out of bootstrap/node.js
- No async operations should be done before the call to
  the setup functions in pre_execution.js so no async hooks should be
  triggered before that. Therefore it is safe to delay the setup
  until then.

PR-URL: https://github.com/nodejs/node/pull/26062
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-21 10:47:24 +08:00
cjihrig
823c988b48
report: remove verbose setting
This commit removes the --diagnostic-report-verbose CLI option
and all associated logic. The flag is currently only used in one
place, and only reflects the settings at startup. Additionally,
Node tends to use the NODE_DEBUG mechanism for adding verbose
output.

PR-URL: https://github.com/nodejs/node/pull/26195
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-02-20 15:15:57 -05:00
Ruben Bridgewater
3d62d0c480
util: update set iterator entries inspection
The inspection output for Set#entries() was wrong so far as it did
not return an array as it should have. That was a bug in V8 that is
now fixed and the code in Node.js has to be updated accordingly.

PR-URL: https://github.com/nodejs/node/pull/25941
Fixes: https://github.com/nodejs/node/issues/24629
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-02-20 18:33:10 +01:00
Anna Henningsen
a34a84d281
src: simplify InspectorConsoleCall
Instead of a JS object, set the is-in-console-call flag as
a boolean in C++.

PR-URL: https://github.com/nodejs/node/pull/26168
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
2019-02-20 16:54:39 +01:00
Ujjwal Sharma
5f8ccecaa2
module: revert module._compile to original state if module is patched
PR-URL: https://github.com/nodejs/node/pull/21573
Fixes: https://github.com/nodejs/node/issues/17396
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-02-19 20:58:37 +05:30
Ujjwal Sharma
d345b0dc12
module: use compileFunction over Module.wrap
Use vm.compileFunction (which is a binding for
v8::CompileFunctionInContext) instead of Module.wrap internally in
Module._compile for the cjs loader.

Fixes: https://github.com/nodejs/node/issues/17396

PR-URL: https://github.com/nodejs/node/pull/21573
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-02-19 20:56:24 +05:30
Abhishek Agarwal
17820ec23f lib: converted element to lowercase in tty.js
Converted the first element "Eterm" in TERM_ENVS array to "eterm"

PR-URL: https://github.com/nodejs/node/pull/26121
Fixes: https://github.com/nodejs/node/issues/26077
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2019-02-19 07:03:13 +01:00
Joyee Cheung
2ae45d3b17
process: start coverage collection before bootstrap
This patch moves the dispatch of `Profiler.takePreciseCoverage`
to a point before the bootstrap scripts are run to ensure that
we can collect coverage data for all the scripts run after
the inspector agent is ready.

Before this patch `lib/internal/bootstrap/primordials.js` was not
covered by `make coverage`, after this patch it is.

PR-URL: https://github.com/nodejs/node/pull/26006
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-18 17:37:33 +08:00
Joyee Cheung
45b7c98f09 src: use PauseOnNextJavascriptStatement to implement --inspect-brk-node
Instead of using the `debugger;` statement which is visible in the
JS source code and makes primordials.js environment-dependent.

PR-URL: https://github.com/nodejs/node/pull/26034
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-18 07:52:47 +01:00
ZYSzys
04c839bd8c lib: convert legacy process.binding to internalBinding
PR-URL: https://github.com/nodejs/node/pull/26095
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-18 07:21:48 +01:00
Anna Henningsen
7f0c515fed
worker: do not add removed methods to MessagePort
Do not put the `.stop()` and `.drain()` methods on the
`MessagePort` prototype if we are going to remove them
later on anyway.

PR-URL: https://github.com/nodejs/node/pull/26109
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-17 17:41:12 +01:00
Rich Trott
a8c3adfbda worker: switch to internal assert module
PR-URL: https://github.com/nodejs/node/pull/26091
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-02-15 21:51:30 -08:00
Joyee Cheung
0eb71d4213
process: delay setup of global exception handlers
Since bootstrap/node.js performs the setup synchronously,
the process exception handlers do not have to setup so early in
the bootstrap process - any fatal errors thrown before user code
execution should simply crash the process, and we do not care
about any clean up at that point. We don't care about emitting any
events if the process crash upon bootstrap either.

PR-URL: https://github.com/nodejs/node/pull/26061
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Gus Caplan <me@gus.host>
2019-02-16 00:16:11 +01:00
Anna Henningsen
5adda2c447
worker: use fake MessageEvent for port.onmessage
Instead of passing the payload for Workers directly to `.onmessage`,
perform something more similar to what the browser API provides,
namely create an event object with a `.data` property.

This does not make `MessagePort` implement the `EventTarget` API, nor
does it implement the full `MessageEvent` API, but it would make
such extensions non-breaking changes if we desire them at
some point in the future.

(This would be a breaking change if Workers were not experimental.
Currently, this method is also undocumented and only exists with
the idea of enabling some degree of Web compatibility.)

PR-URL: https://github.com/nodejs/node/pull/26082
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
2019-02-15 23:16:16 +01:00
Ali Ijaz Sheikh
a02e3e2d5f lib: improve error message for MODULE_NOT_FOUND
Include the require stack in the reported error message.

PR-URL: https://github.com/nodejs/node/pull/25690
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-15 12:52:05 -08:00
Ali Ijaz Sheikh
05cd1a0929 lib: requireStack property for MODULE_NOT_FOUND
Include the stack of requires that led to a MODULE_NOT_FOUND error.

PR-URL: https://github.com/nodejs/node/pull/25690
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-15 12:51:53 -08:00
Richard Lau
51d20b6a8f fs, src, lib: fix blksize & blocks on Windows
libuv returns values for `blksize` and `blocks` on stat calls so
do not coerce them into `undefined` on Windows.

PR-URL: https://github.com/nodejs/node/pull/26056
Fixes: https://github.com/nodejs/node/issues/25913
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-15 01:55:58 -05:00
MaleDong
1411f7c8b3
lib: merge 'undefined' into one 'break' branch
We don't need to split this alone, but just merge it into the 'break'
switch branch together.

PR-URL: https://github.com/nodejs/node/pull/26039
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-14 00:03:02 +01:00
Rich Trott
4aa04f57c3
cluster: migrate round_robin_handle to internal assert
Use smaller internal assert module for round_robin_handle.js.

PR-URL: https://github.com/nodejs/node/pull/26047
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-14 00:00:51 +01:00
Rich Trott
ce65034e63
assert: add internal assert.fail()
PR-URL: https://github.com/nodejs/node/pull/26047
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-14 00:00:50 +01:00
MaleDong
ec76f7cf8f lib: simplify 'umask'
Just check: if 'mask' is not undefined, just call 'validateMode' and
then return the unmask value, we don't need split them into two returns.

PR-URL: https://github.com/nodejs/node/pull/26035
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-13 13:45:38 +01:00
MaleDong
048b977d8e lib: fix the typo error
Fix a typo error ('the' before 'any').

PR-URL: https://github.com/nodejs/node/pull/26032
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Lance Ball <lball@redhat.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-13 05:22:58 +01:00
Joyee Cheung
006e78cecb
process: refactor lib/internal/bootstrap/node.js
- Use `deprecate` from `internal/util` instead of from `util`
- Split `setupGlobalVariables()` into `setupGlobalProxy()` and
  `setupBuffer()`, and move out manipulation of the process object.

PR-URL: https://github.com/nodejs/node/pull/26033
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-13 06:11:48 +08:00
Joyee Cheung
e5da922668
process: use primordials in bootstrap/node.js
PR-URL: https://github.com/nodejs/node/pull/26033
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-13 06:11:46 +08:00
Joyee Cheung
fda80e3c99
lib: save a copy of Symbol in primordials
PR-URL: https://github.com/nodejs/node/pull/26033
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-13 06:11:44 +08:00
Joyee Cheung
008074fc38
process: document the bootstrap process in node.js
PR-URL: https://github.com/nodejs/node/pull/26033
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-13 06:11:43 +08:00
Joyee Cheung
68afae2f22
lib: move per_context.js under lib/internal/bootstrap
PR-URL: https://github.com/nodejs/node/pull/26033
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-13 06:11:41 +08:00
Joyee Cheung
af83f6af5d
process: normalize process.execPath in CreateProcessObject()
Directly normalize `process.execPath` using `uv_fs_realpath`
on OpenBSD before serializing it into the process object,
instead of using `require('fs')` to normalize and override
the path in `bootstrap/node.js`.

PR-URL: https://github.com/nodejs/node/pull/26002
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-12 10:26:38 +08:00
Anna Henningsen
9e84a26cb3
worker: keep stdio after exit
This addresses review comments from
https://github.com/nodejs/node/pull/25871.

Refs: https://github.com/nodejs/node/pull/25871

PR-URL: https://github.com/nodejs/node/pull/26017
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-02-12 01:17:13 +01:00
Lance Ball
0aa74443d8
repl: add repl.setupHistory for programmatic repl
Adds a `repl.setupHistory()` instance method so that
programmatic REPLs can also write history to a file.

This change also refactors all of the history file
management to `lib/internal/repl/history.js`, cleaning
up and simplifying `lib/internal/repl.js`.

PR-URL: https://github.com/nodejs/node/pull/25895
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2019-02-11 14:30:26 -05:00
Matteo Collina
9af04ad684 http2: improve compat performance
This bunch of commits help me improve the performance of a http2
server by 8-10%. The benchmarks reports several 1-2% improvements in
various areas.

PR-URL: https://github.com/nodejs/node/pull/25567
Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-11 08:50:07 +01:00
Rich Trott
1847696f4b util: protect against monkeypatched Object prototype for inspect()
Prevent affects of monkeypatching (for example) Object.keys() when
calling util.inspect().

PR-URL: https://github.com/nodejs/node/pull/25953
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-02-10 12:51:38 -08:00
Joyee Cheung
69714ab1c4
process: normalize process.argv before user code execution
And make sure that `process.argv` from the preloaded modules
is the same as the one in the main module.

Refs: https://github.com/nodejs/node/issues/25967
PR-URL: https://github.com/nodejs/node/pull/26000
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2019-02-10 16:34:19 +08:00
Joyee Cheung
84000835e2
process: group main thread execution preparation code
This patch groups the preparation of main thread execution into
`prepareMainThreadExecution()` and removes the cluster IPC
setup in worker thread bootstrap since clusters do not use
worker threads for its implementation and it's unlikely to change.

PR-URL: https://github.com/nodejs/node/pull/26000
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2019-02-10 16:33:57 +08:00
ZYSzys
70f4f08a9f fs: harden validation of start option in createWriteStream
PR-URL: https://github.com/nodejs/node/pull/25579
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-02-10 09:22:36 +01:00
cjihrig
e154176b7c
report: rename setDiagnosticReportOptions()
setDiagnosticReportOptions() is a method on process.report,
making the "DiagnosticReport" part redundant. Rename the
function to setOptions().

PR-URL: https://github.com/nodejs/node/pull/25990
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-02-09 17:09:51 -05:00
cjihrig
46c16b3cae
report: refactor report option validation
PR-URL: https://github.com/nodejs/node/pull/25990
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-02-09 17:09:03 -05:00
Christopher Jeffrey
2fc759b9b8
worker: no throw on property access/postMessage after termination
PR-URL: https://github.com/nodejs/node/pull/25871
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-09 17:27:05 +01:00
Amit Zur
e0a3d74135
crypto: include 'Buffer' in error output of Hash.update method
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-09 17:21:41 +01:00
Mark S. Everitt
1aa11e1444
http2: makes response.writeHead return the response
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-09 16:34:25 +01:00
Anna Henningsen
de9d5ff287
worker: use correct ctor for error serialization
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-08 21:30:59 +01:00
Michaël Zasso
582c12260e
deps: update acorn to 6.0.7
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-08 15:34:10 +01:00
Rich Trott
62942e9ad7 lib: replace 'assert' with 'internal/assert' for many built-ins
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-08 00:01:12 -08:00
Rich Trott
5d609bb11c assert: create internal/assert micro-module
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-08 00:01:09 -08:00
Rich Trott
64745c3ade assert: refactor internal assert.js
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-08 00:01:07 -08:00
Joyee Cheung
b44131ab92
lib: use internal/options to query --abort-on-uncaught-exception
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-08 08:09:56 +08:00
Joyee Cheung
09a5f0252e
process: move deprecation warning initialization into pre_execution.js
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-08 08:08:48 +08:00
Joyee Cheung
041424f87c
lib: move signal event handling into bootstrap/node.js
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-08 07:10:50 +08:00
Rich Trott
6da82b1057 worker: remove undocumented .onclose property
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-06 08:55:43 -08:00
Robin Neatherway
106dd1e345 lib: fix a few minor issues flagged by lgtm
* 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-06 11:09:29 -05:00
Gireesh Punathil
b1f82e4342 child_process: close pipe ends that are re-piped
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-06 17:50:46 +05:30
cjihrig
12b3cfcea6
process: stub unsupported worker methods
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-05 18:50:10 -05:00
Anna Henningsen
39eca841c3
src: split ownsProcessState off isMainThread
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-05 21:55:54 +01:00
Anna Henningsen
270ffb0fa7
src,lib: remove dead process.binding() code
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-03 20:41:53 +01:00
Anna Henningsen
cca897ef5d
inspector,vm: remove --eval wrapper
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-03 20:40:16 +01:00
Joyee Cheung
fa5e097530
process: move DEP0062 (node --debug) to end-of-life
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-02 05:45:05 +08:00
Joyee Cheung
154efc9bde
process: exit on --debug and --debug-brk after option parsing
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-02 05:45:05 +08:00
Joyee Cheung
406329de57
process: move process mutation into bootstrap/node.js
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-02 05:42:48 +08:00
Joyee Cheung
c2359bdad6
process: expose process.features.inspector
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-02 05:41:45 +08:00
Joyee Cheung
39d922123c
lib: save primordials during bootstrap and use it in builtins
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-02 05:40:47 +08:00
Anna Henningsen
393c196605
worker: refactor thread id management
- 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-01 20:22:33 +01:00
cjihrig
973c223429
report: fix typo in error message
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-31 13:00:24 -05:00
cjihrig
dc1d331403
process: simplify report uncaught exception logic
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-30 19:43:45 -05:00
cjihrig
5aa89d616f
lib: refactor ERR_SYNTHETIC
- 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-30 15:52:46 -05:00
Anna Henningsen
7fa5157497
module: do not use process.exit()
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-30 18:17:26 +01:00
Anna Henningsen
94ebf3f0a7
module: silence ModuleJob unhandled rejection warnings
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-30 18:17:06 +01:00
Joyee Cheung
5e1d4462d2
worker: move worker thread setup code into the main script
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-30 21:03:19 +08:00
Joyee Cheung
6967f91368
process: split execution into main scripts
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-30 21:03:17 +08:00
Bradley Farias
78982389ce policy: ensure workers do not read fs for policy
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-29 08:08:50 +01:00
Ben Noordhuis
f399b01dc4
dns: use IDNA 2008 to encode non-ascii hostnames
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-28 20:42:44 +01:00
ZYSzys
802ea05a37
net,http2: merge setTimeout code
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-27 17:20:13 +01:00
Ruben Bridgewater
7493db21b6
assert: adjust loose assertions
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-27 03:34:25 +01:00
Anna Henningsen
f8d52c25c4 src: remove has_experimental_policy option
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-25 07:36:49 +01:00
Anna Henningsen
0f5c14c43e lib: refactor policy code for readability
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-25 07:24:22 +01:00
Anna Henningsen
3260a4aa87
report: remove internalBinding('config').hasReport
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-24 20:36:31 +01:00
Daniel Bevenius
47062f12a7 crypto: add crypto modules to cannotUseCache
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-24 05:23:53 +01:00
Benjamin Coe
a6286e64c5
process: fix call process.reallyExit, vs., binding
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-23 10:19:17 -08:00
Anna Henningsen
2b65399694
http2: allow fully synchronous _final()
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-23 16:32:20 +01:00
Joyee Cheung
d3806f9f3c
console: refactor inspector console extension installation
- 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-23 20:23:23 +08:00
Joyee Cheung
a93c825d78
process: clarify the pre- and post-condition of esm setup
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-23 19:21:56 +08:00
Benjamin Coe
d1dee495db
test: switch to native v8 coverage
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-20 14:21:16 -08:00
Tobias Nießen
9315daaf02
crypto: fix key handle extraction
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-18 14:55:29 +01:00
Ruben Bridgewater
2c0a75118c util: fix iterable types with special prototype
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-18 08:03:25 +01:00
LakshmiSwethaG
55e0ad9ae6 test: add node-report tests
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-18 10:36:39 +05:30
Gireesh Punathil
4f6797378e src: merge into core
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-18 10:34:04 +05:30
Yael Hermon
01cd21973b worker: enable passing command line flags
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-18 05:39:58 +01:00
cjihrig
f6cd4e3e59
process: allow reading umask in workers
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-17 16:32:21 -05:00
Bradley Farias
9d5fbeb55f policy: manifest with subresource integrity checks
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-17 09:43:42 -06:00
Joyee Cheung
cd70cbcbdd
src: pass cli options to bootstrap/loaders.js lexically
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-16 21:54:23 +08:00
Joyee Cheung
6b2af91a88
process: register the inspector async hooks in bootstrap/node.js
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-16 16:19:22 +08:00
Joyee Cheung
b367ab2a66
process: refactor coverage setup during bootstrap
- 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-16 13:49:36 +08:00
Joyee Cheung
2c7f4f474b
process: allow StartExecution() to take a main script ID
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-16 03:42:41 +08:00
Joyee Cheung
92e95f17b6
src: simplify NativeModule caching and remove redundant data
- 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-12 22:56:02 +08:00
Ruben Bridgewater
6cc74b038f util: remove eslint comments and rename variables
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-11 07:32:31 +01:00
Ruben Bridgewater
1bee544a20 util: remove outdated comment
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-11 07:32:26 +01:00
Ruben Bridgewater
1ab659a141 util: simpler module namespace code
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-11 07:32:17 +01:00
Ruben Bridgewater
76fa37af75 util: code cleanup
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-11 07:32:14 +01:00
Ruben Bridgewater
eca2760ab1 util: switch recurseTimes counter
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-11 07:31:55 +01:00
Kevin Smith
7237eaa335 url: return backslashes from fileURLToPath on win
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>
2019-01-11 07:17:44 +01:00
Joyee Cheung
842a35fbac
buffer: move Buffer prototype wiring into internal/buffer.js
Instead of exposing the Buffer prototype methods through an
object in `internal/buffer.js` and then iterating over it
to put the methods on the prototype, create a function
in `internal/buffer.js` to do this.

Also moves the creaton of the `FastBuffer` class into
`internal/buffer.js` and expose it directly instead of
writing it onto that module later.

PR-URL: https://github.com/nodejs/node/pull/25292
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-01-10 16:59:27 +08:00
Joyee Cheung
97f59b9567
buffer: move initialization of buffer prototype into node.js
Instead of exposing it in `lib/internal/buffer.js` after deleting
it from the binding and then do the initialization in
`lib/buffer.js`, which results in an implicit dependency on
the order in which these modules are loaded.

PR-URL: https://github.com/nodejs/node/pull/25292
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-01-10 16:59:24 +08:00
Ruben Bridgewater
dfaa61fa18
assert: make actual and expected getters
The `actual` and `expected` properties on an instance of
`AssertionError` is now a getter to prevent inspecting these when
inspecting the error. These values will be visible in the error
message and showing them otherwise would decrease the readability
of the error.

PR-URL: https://github.com/nodejs/node/pull/25250
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-10 03:26:50 +01:00
Anto Aravinth
81b25eac21
util: add null prototype support for date
PR-URL: https://github.com/nodejs/node/pull/25144
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-10 03:24:31 +01:00
Kazushi Kitaya
7635b02e29
util: update comment in util.promisify
child_process.exec has Symbol('util.promisify.custom') in its keys
and no longer has Symbol('customPromisifyArgs') in its keys, but it was
still used as an example of funtions with
Symbol('customPromisifyArgs').

PR-URL: https://github.com/nodejs/node/pull/25323
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
2019-01-09 01:38:54 +01:00
ZYSzys
98ed23cfaa
fs: extract start and end check into checkPosition
PR-URL: https://github.com/nodejs/node/pull/25264
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-01-09 01:37:42 +01:00
Ruben Bridgewater
aa07dd6248
util: inspect ArrayBuffers contents as well
Inspecting an ArrayBuffer now also shows their binary contents.

PR-URL: https://github.com/nodejs/node/pull/25006
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-01-09 01:34:25 +01:00
Anna Henningsen
63d4cae009
worker: remove --experimental-worker flag
Having an experimental feature behind a flag makes change
if we are expecting significant breaking changes to its API.

Since the Worker API has been essentially stable since
its initial introduction, and no noticeable doubt about
possibly not keeping the feature around has been voiced,
removing the flag and thereby reducing the barrier to experimentation,
and consequently receiving feedback on the implementation,
seems like a good idea.

PR-URL: https://github.com/nodejs/node/pull/25361
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2019-01-09 00:31:33 +01:00
Tobias Nießen
ae2d1f0e05
crypto: always accept private keys as public keys
Some APIs already accept private keys instead of public keys. This
changes all relevant crypto APIs to do so.

PR-URL: https://github.com/nodejs/node/pull/25217
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
2019-01-08 00:20:09 +01:00
Tobias Nießen
7afdfaec08 crypto: fix key object wrapping in sync keygen
PR-URL: https://github.com/nodejs/node/pull/25326
Fixes: https://github.com/nodejs/node/issues/25322
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-07 07:33:35 +01:00
Joyee Cheung
d18b0a0132
process: make tick callback and promise rejection callback more robust
- Rename `internalTickCallback` to `processTicksAndRejections`, make
  sure it does not get called if it's not set in C++.
- Rename `emitPromiseRejectionWarnings` to `processPromiseRejections`
  since it also emit events that are not warnings.
- Sets `SetPromiseRejectCallback` in the `Environment` constructor
  to make sure it only gets called once per-isolate, and make
  sure it does not get called if it's not set in C++.
- Wrap promise rejection callback initialization into
  `listenForRejections()`.
- Add comments.

PR-URL: https://github.com/nodejs/node/pull/25200
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-06 10:28:47 +08:00
Joyee Cheung
bf566718b2
src: refactor tickInfo access
- Wrap access to tickInfo fields in functions
- Rename `kHasScheduled` to `kHasTickScheduled` and
  `kHasPromiseRejections` to `kHasRejectionToWarn` for clarity - note
  the latter will be set to false if the rejection does not lead to
  a warning so the previous description is not accurate.
- Set `kHasRejectionToWarn` in JS land of relying on C++ to use
  an implict contract (return value of the promise rejection handler)
  to set it, as the decision is made entirely in JS land.
- Destructure promise reject event constants.

PR-URL: https://github.com/nodejs/node/pull/25200
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-06 10:28:44 +08:00
Anna Henningsen
f6a1d88c5d
src: split LoadEnvironment() at startExecution()
This makes it easier to cater to embedders which wish to skip
the `startExecution()` part.

PR-URL: https://github.com/nodejs/node/pull/25320
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2019-01-06 02:15:47 +01:00
Anna Henningsen
73753d4863
zlib: add brotli support
Refs: https://github.com/nodejs/node/pull/20458

Co-authored-by: Hackzzila <admin@hackzzila.com>

PR-URL: https://github.com/nodejs/node/pull/24938
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2019-01-05 21:36:46 +01:00
Anna Henningsen
9dfbc391fa
worker: improve JS-side debugging
Do not print debug messages that indicate that a stdio stream
has drained; because `util.debuglog()` uses `console.log`, which
in turn uses stdio streams, this would otherwise have lead to an
endless loop.

PR-URL: https://github.com/nodejs/node/pull/25312
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-04 19:27:38 +01:00
Joyee Cheung
b22c86ed3b
src: use internalBinding('config').hasInspector in JS land
Instead of `process.config.variables.v8_enable_inspector`
which depends on the variable name in gyp files, or detecting
`internalBinding('inspector').Connection`.

PR-URL: https://github.com/nodejs/node/pull/25291
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-05 01:25:31 +08:00
Rich Trott
7e15f0490a lib,test: remove lib/internal/test/unicode.js
Remove lib/internal/test/unicode.js and associated test. When we added
the file and test, only comments in lib had non-ASCII characters. Now,
lib/internal/cli_table.js has non-ASCII characters. Tests that exercise
the `console.table()` therefore fulfill the need to test non-ASCII
characters in built-in modules.

PR-URL: https://github.com/nodejs/node/pull/25298
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-03 10:25:59 -08:00
cjihrig
a779ee4fad
coverage: pass cwd to path.resolve() in setup
During coverage setup, path.resolve() is called.
path.resolve() can potentially call process.cwd(), which
hasn't been bootstrapped yet. This commit passes the
current working directory directly so that path.resolve()
doesn't attempt to compute it.

PR-URL: https://github.com/nodejs/node/pull/25289
Fixes: https://github.com/nodejs/node/issues/25287
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-01 19:36:34 -05:00
cjihrig
d32f769d75
coverage: use process._rawDebug() during setup
console is not ready to use at this point in the bootstrapping
process, so switch to process._rawDebug() instead.

PR-URL: https://github.com/nodejs/node/pull/25289
Fixes: https://github.com/nodejs/node/issues/25287
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-01 19:36:19 -05:00
Joyee Cheung
ee12607c1c
process: move --help and --bash-completeion handling to startExecution
Because they are similar to `--prof-process` and are part of
the execution instead of initialization.
Also move the `getOptionValue` initialization to top scope since
it's used everywhere and add comments about the flags.

PR-URL: https://github.com/nodejs/node/pull/25262
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-12-31 15:23:48 +08:00
Joyee Cheung
0878b6172e
process: move setup of process warnings into node.js
To clarify the side effects and conditions of the warning setup
during bootstrap.

PR-URL: https://github.com/nodejs/node/pull/25263
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2018-12-31 15:10:00 +08:00
Daniel Bevenius
d28980c464 crypto: add crypto/keys to cannotUseCache
Currently when configuring --without-ssl test-code-cache.js will fail
with the following error:
internal/bootstrap/loaders.js:151
      mod = bindingObj[module] = getInternalBinding(module);
                                 ^

Error: No such module: crypto
    at internalBinding (internal/bootstrap/loaders.js:151:34)
    at internal/crypto/keys.js:14:5
    at NativeModule.compile (internal/bootstrap/loaders.js:342:5)
    at Function.NativeModule.require (internal/bootstrap/loaders.js:213:16)
    at Function.Module._load (internal/modules/cjs/loader.js:539:25)
    at Module.require (internal/modules/cjs/loader.js:654:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/node/test/code-cache/test-code-cache.js:31:3)
    at Module._compile (internal/modules/cjs/loader.js:718:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:729:10)

This commit adds internal/crypto/keys to the cannotUseCache array if
compiled without crypto support.

PR-URL: https://github.com/nodejs/node/pull/25237
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2018-12-31 07:34:25 +01:00
Joyee Cheung
00babd38f3
process: move worker bootstrap code into worker_thread_only.js
Move worker bootstrap code into worker_thread_only.js from
internal/worker.js since they are only run once during bootstrap.

PR-URL: https://github.com/nodejs/node/pull/25199
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-31 14:19:51 +08:00
Joyee Cheung
af237152cd
process: split worker IO into internal/worker/io.js
- Move `setupProcessStdio` which contains write access to
  the process object into `bootstrap/node.js`
- Move `MessagePort`, `MessageChannel`, `ReadableWorkerStdio`,
  and `WritableWorkerStdio` into `internal/worker/io.js`
- Move more worker-specific bootstrap code into
  `internal/process/worker_thread_only` from `setupChild`
  in `internal/worker.js`, and move the `process._fatalException`
  overwrite into `bootstrap/node.js` for clarity.

PR-URL: https://github.com/nodejs/node/pull/25199
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-31 14:19:49 +08:00
Joyee Cheung
7163fbf066
process: move eval and exception bootstrap ito process/execution.js
This patch:

- Moves `tryGetCwd`, `evalScript` and `fatalException` from
  `bootstrap/node.js` into `process/execution.js` so that
  they do have to be passed into the worker thread
  setup function, instead the worker code can require them
  when necessary.
- Moves `setUncaughtExceptionCaptureCallback` and
  `hasUncaughtExceptionCaptureCallback` along with the two
  global state `exceptionHandlerState` and
  `shouldAbortOnUncaughtToggle` info `process.execution.js`
  as those are only used by the fatalException and these
  two accessors as one self-contained unit.

PR-URL: https://github.com/nodejs/node/pull/25199
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-31 14:19:48 +08:00
Joyee Cheung
39a2ac4c6b
process: move process.features initialization into node.js
Use `internalBinding('config')` to shim the legacy
`process.features`.

PR-URL: https://github.com/nodejs/node/pull/25239
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2018-12-31 01:20:33 +01:00
Weijia Wang
6c7c77ef05
util: fix util.inspect with proxied function
PR-URL: https://github.com/nodejs/node/pull/25244
Fixes: https://github.com/nodejs/node/issues/25212
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
2018-12-31 01:19:18 +01:00
Anna Henningsen
4100001624
lib: remove unintended access to deps/
This brings DEP0084 to End-of-Life. It is unlikely that this
has received much public usage in the first place, so removing
should be okay.

PR-URL: https://github.com/nodejs/node/pull/25138
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-12-30 20:17:19 +01:00
cjihrig
69470c87cc
lib: simplify several debug() calls
Avoid calling Array.prototype.join() in debug() calls. These
are evaluated on every call, even if the debug() call is a
no-op. This commit replaces the join() calls with the %j
placeholder.

PR-URL: https://github.com/nodejs/node/pull/25241
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-29 13:51:35 -05:00