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

7191 Commits

Author SHA1 Message Date
Anna Henningsen
d5cf51dad5 worker: only unref port for stdin if we ref’ed it before
We set the `kStartedReading` flag from `_read()` for Worker stdio,
and then `ref()` the port.

However, the `.on('end')` handler is also attached when `._read()`
is not called, e.g. when `process.stdin` inside a Worker is prematurely
ended because stdin was not enabled by the parent thread.

In that case, we should not call `.unref()` for stdin if we did not
also call `.ref()` for it before.

Fixes: https://github.com/nodejs/node/issues/28144
PR-URL: https://github.com/nodejs/node/pull/28153
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-06-20 11:27:27 -06:00
Joyee Cheung
a33c3c6d33
src: refactor uncaught exception handling
The C++ land `node::FatalException()` is not in fact fatal anymore.
It gives the user a chance to handle the uncaught exception
globally by listening to the `uncaughtException` event. This patch
renames it to `TriggerUncaughtException` in C++ to avoid the confusion.

In addition rename the JS land handler to `onGlobalUncaughtException`
to reflect its purpose - we have to keep the alias
`process._fatalException` and use that for now since it has been
monkey-patchable in the user land.

This patch also

- Adds more comments to the global uncaught exception handling routine
- Puts a few other C++ error handling functions into the `errors`
  namespace
- Moves error-handling-related bindings to the `errors` binding.

Refs: 2b252acea4

PR-URL: https://github.com/nodejs/node/pull/28257
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2019-06-19 16:16:37 +08:00
Joyee Cheung
1c23b6f2be
lib: refactor unhandled rejection deprecation warning emission
Emit the deprecation warning in the `kDefaultUnhandledRejections`
case to reduce the number of branches on unhandled rejection mode -
there is now only one switch case on it.

Also rename `emitWarning()` to `emitUnhandledRejectionWarning()`
to avoid ambiguity with `process.emitWarning()`

PR-URL: https://github.com/nodejs/node/pull/28258
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2019-06-19 15:44:09 +08:00
Ruben Bridgewater
14be3aa6e6 process: hide NodeEnvironmentFlagsSet's add function
This makes sure that the `add` function is not visible by default
when inspecting `process.allowedNodeEnvironmentFlags`.

PR-URL: https://github.com/nodejs/node/pull/28206
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-17 15:25:56 -07:00
Daniel Bevenius
c925d1dcaa tls: remove unnecessary set of DEFAULT_MAX_VERSION
This commit removes what looks like an unnecessary setting of
exports.DEFAULT_MAX_VALUE.

PR-URL: https://github.com/nodejs/node/pull/28147
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-17 14:39:41 +02:00
Anna Henningsen
ed24c19002
worker: refactor worker.terminate()
At the collaborator summit in Berlin, the behaviour of
`worker.terminate()` was discussed.

In particular, switching from a callback-based to a Promise-based API
was suggested. While investigating that possibility later, it was
discovered that `.terminate()` was unintentionally synchronous up
until now (including calling its callback synchronously).

Also, the topic of its stability has been brought up. I have performed
two manual reviews of the native codebase for compatibility with
`.terminate()`, and performed some manual fuzz testing with the test
suite. At this point, bugs with `.terminate()` should, in my opinion,
be treated like bugs in other Node.js features.
(It is possible to make Node.js crash with `.terminate()` by messing
with internals and/or built-in prototype objects, but that is already
the case without `.terminate()` as well.)

This commit:

- Makes `.terminate()` an asynchronous operation.
- Makes `.terminate()` return a `Promise`.
- Runtime-deprecates passing a callback.
- Removes a warning about its stability from the documentation.
- Eliminates an unnecessary extra function from the C++ code.

A possible alternative to returning a `Promise` would be to keep the
method synchronous and just drop the callback. Generally, providing
an asynchronous API does provide us with a bit more flexibility.

Refs: https://github.com/nodejs/summit/issues/141

PR-URL: https://github.com/nodejs/node/pull/28021
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-06-17 08:27:17 -04:00
Sam Roberts
574985cec8
https: do not automatically use invalid servername
Stop automatically setting servername in https.request() if the target
host is specified with an IP address. Doing so is invalid, and triggers
a deprecation warning. It is still possible to send an IP address as a
servername if its required, but it needs to be explicity configured, it
won't happen automatically.

PR-URL: https://github.com/nodejs/node/pull/28209
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-06-17 11:58:26 +02:00
Joyee Cheung
b6326ce0f7
fs: document the Date conversion in Stats objects
Document why the dates are calculated with the timestamp
in Numbers + 0.5.

The comment was previously lost in a revert.

Refs: ae6c7044c8

PR-URL: https://github.com/nodejs/node/pull/28224
Refs: ae6c7044c8
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-06-17 11:54:34 +02:00
Ruben Bridgewater
b97b003c35
util: use average bias while grouping arrays
This makes sure that strongly deviating entry length are taken into
account while grouping arrays.

PR-URL: https://github.com/nodejs/node/pull/28070
Refs: https://github.com/nodejs/node/issues/27690
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-06-17 11:49:42 +02:00
Ruben Bridgewater
87a22cff77
util: improve .inspect() array grouping
This improves a couple minor things:

* Arrays that contain entries other than `number` or `bigint` are
  ordered to the left instead of the right.
* The bias towards more columns got increased. That mainly increases
  the number of columns for arrays that contain lots of short entries.
* Columns are now more dense in case they would otherwise have extra
  whitespace in-between two columns.
* The maximum columns got increased from 10 to 15.
* The maximum number of columns per `compact` was increased from
  3 to 4.

PR-URL: https://github.com/nodejs/node/pull/28070
Refs: https://github.com/nodejs/node/issues/27690
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-06-17 11:49:41 +02:00
Joyee Cheung
370873c59e
process: refactor unhandled rejection handling
- Use constants instead of a dictionary and add comments
  about the behavior of each mode.
- Use switch cases to handle the unhandled rejection modes.
- Rename the run time value of the CLI option from `state`
  to `unhandledRejectionsMode`.
- Return in the call site of `emitWarning` when
  `--unhandled-rejections=none` instead of inside
  the function.

PR-URL: https://github.com/nodejs/node/pull/28228
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-06-17 10:24:12 +08:00
Joyee Cheung
1432065e9d
lib: correct error.errno to always be numeric
Historically `error.errno` of system errors thrown by Node.js
can sometimes be the same as `err.code`, which are string
representations of the error numbers. This is useless and incorrect,
and results in an information loss for users since then they
will have to resort to something like
`process.binding('uv'[`UV_${errno}`])` to get to the numeric
error codes.

This patch corrects this behavior by always setting `error.errno`
to be negative numbers. For fabricated errors like `ENOTFOUND`,
`error.errno` is now undefined since there is no numeric equivalent
for them anyway. For c-ares errors, `error.errno` is now undefined
because the numeric representations (negated) can be in conflict
with libuv error codes - this is fine since numeric codes was
not available for c-ares errors anyway.

Users can use the public API `util.getSystemErrorName(errno)`
to retrieve string codes for these numbers.

PR-URL: https://github.com/nodejs/node/pull/28140
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-06-17 10:18:09 +08:00
cjihrig
2b8b23067d perf_hooks,trace_events: use stricter equality
There is no need to use loose equality on these checks because
undefined is caught by the preceding typeof check.

PR-URL: https://github.com/nodejs/node/pull/28166
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2019-06-16 16:45:15 +08:00
Ruben Bridgewater
9939762322
module: prevent race condition while combining import and require
This checks if any require calls have happened to the same file
during the file read. If that was the case, it'll return the same
module instead of creating a new instance.

PR-URL: https://github.com/nodejs/node/pull/27674
Reviewed-By: Guy Bedford <guybedford@gmail.com>
2019-06-15 11:23:03 +02:00
Joyee Cheung
b245257b70
fs: add *timeNs properties to BigInt Stats objects
- Extend the aliased buffer for stats objects to contain
  the entire time spec (seconds and nanoseconds) for the time
  values instead of calculating the milliseconds in C++ and
  lose precision there.
- Calculate the nanosecond-precision time values in JS and expose
  them in BigInt Stats objects as `*timeNs`. The
  millisecond-precision values are now calculated from the
  nanosecond-precision values.

PR-URL: https://github.com/nodejs/node/pull/21387
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
2019-06-14 03:24:41 +08:00
Julien Gilli
43a5170858 domain: error handler runs outside of its domain
Before this change, domains' error handlers would run with the
corresponding domain as the active domain. This creates the
possibility for domains' error handlers to call themselves recursively
if an event emitter created in the error handler emits an error, or if
the error handler throws an error.

This change sets the active domain to be the domain's parent (or null
if the domain for which the error handler is called has no parent) to
prevent that from happening.

Fixes: https://github.com/nodejs/node/issues/26086
PR-URL: https://github.com/nodejs/node/pull/26211
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-12 22:01:07 -07:00
Daniel Bevenius
173bee230e tls: rename validateKeyCert in _tls_common.js
This commit renames validateKeyCert to validateKeyCertArg to avoid
confusing this with something that would validate the actual key or
certificate.

PR-URL: https://github.com/nodejs/node/pull/28116
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-12 20:58:27 -07:00
Ruben Bridgewater
1a0fd60277 assert: add partial support for evaluated code in simple assert
This makes sure using `assert.ok()` in `new Function()` statements
visualizes the actual call site in the error message.

PR-URL: https://github.com/nodejs/node/pull/27781
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-12 20:02:50 -07:00
Ruben Bridgewater
4a3af65a88 assert: improve regular expression validation
This makes sure `assert.throws()` and `assert.rejects()` result in
an easy to understand error message instead of rethrowing the actual
error. This should significantly improve the debugging experience in
case people use an regular expression to validate their errors.

This also adds support for primitive errors that would have caused
runtime errors using the mentioned functions. The input is now
stringified before it's passed to the RegExp to circumvent that.

As drive-by change this also adds some further comments and renames
a variable for clarity.

PR-URL: https://github.com/nodejs/node/pull/27781
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-12 20:02:48 -07:00
Ruben Bridgewater
81496567e7 assert: print more lines in the error diff
So far consequitive identical lines were collapsed if there were at
least three. Now they are only collapsed from five identical lines on.

This also simplifies the implementation a tiny bit by abstracting some
logic.

PR-URL: https://github.com/nodejs/node/pull/28058
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-12 19:50:03 -07:00
Ruben Bridgewater
e4ec4f2656 assert: fix error diff
In some edge cases an identical line could be printed twice. This is
now fixed by changing the algorithm a bit. It will now verify how
many lines were identical before the current one.

PR-URL: https://github.com/nodejs/node/pull/28058
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-12 19:49:59 -07:00
Ruben Bridgewater
a3ea54f5ab assert: limit string inspection when logging assertion errors
This makes sure long strings as `actual` or `expected` values on an
`AssertionError` won't be logged completely. This is important as
the actual value is somewhat redundant in combination with the error
message which already logs the difference between the input values.

PR-URL: https://github.com/nodejs/node/pull/28058
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-12 19:48:24 -07:00
cjihrig
58fc168807
module: handle empty require.resolve() options
If require.resolve() is passed an options object, but
the paths option is not present, then use the default
require.resolve() paths.

PR-URL: https://github.com/nodejs/node/pull/28078
Fixes: https://github.com/nodejs/node/issues/28077
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-06-11 10:20:31 -07:00
Ruben Bridgewater
26de13a15c
util: refactor inspecting long lines
Using the `util.inspect` `compact` mode set to something else than
`true` resulted in breaking long lines in case the line would exceed
the `breakLength` option and if it contained whitespace and or new
lines.

It turned out that this behavior was less useful than originally
expected and it is now changed to only break on line breaks if the
`breakLength` option is exceeded for the inspected string. This should
be align better with the user expectation than the former behavior.

PR-URL: https://github.com/nodejs/node/pull/28055
Fixes: https://github.com/nodejs/node/issues/27690
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-11 13:50:55 +02:00
Sam Roberts
04633eeeb9 readline: error on falsy values for callback
It was intended, according to in-test comments and common behaviour,
that callbacks be either `undefined` or a function, but falsy values
were being accepted as meaning "no callback".

PR-URL: https://github.com/nodejs/node/pull/28109
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-06-10 11:09:40 -07:00
cjihrig
d1dd4e10db
dgram: fix abort on bad args
This commit fixes a C++ abort for connected dgram sockets
by improving input validation in the JS layer.

Fixes: https://github.com/nodejs/node/issues/28126
PR-URL: https://github.com/nodejs/node/pull/28135
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-06-10 09:14:13 -07:00
Antonio Kukas
bcf11356b3
http2: do not register unnecessary listeners
PR-URL: https://github.com/nodejs/node/pull/27987
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-06-10 17:16:10 +02:00
Anatoli Papirovski
cde3928a10 process: improve queueMicrotask performance
Optimize the hot code paths of queueMicrotask by
not creating unnecessary objects, not looking up
properties on frozen primordials, etc.

PR-URL: https://github.com/nodejs/node/pull/28093
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-06-10 07:49:40 +02:00
Daniel Bevenius
5bad51406d crypto: add debug info client emit secureConnect
Currently, when debugging a TLS connection there might be multiple debug
statements 'client emit secureConnect' for the 'secureConnect` event
when using NODE_DEBUG='tls'. While it is possible to step through this
with a debugger that is not always the fastest/easiest to do if
debugging remote code.

This commit adds some additional information to the debug statements to
make it easier to distinguish where the debug statements are coming
from.

PR-URL: https://github.com/nodejs/node/pull/28067
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-10 05:29:10 +02:00
Daniel Nalborczyk
0c1fd20693 util: use Set to store deprecation codes
PR-URL: https://github.com/nodejs/node/pull/28113
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-09 10:05:40 -07:00
Ruben Bridgewater
0059b877e3 util: special handle maxArrayLength while grouping arrays
This makes sure that large arrays with lots of small entries ignore
the `... n more item(s)` part since it often resulted in output that
users did not expect.

Now that part is printed on a separate line to indicate extra entries.

PR-URL: https://github.com/nodejs/node/pull/28059
Refs: https://github.com/nodejs/node/issues/27690
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-09 14:35:31 +05:30
Samuel Attard
97a42465ab src: only run preloadModules if the preload array is not empty
PR-URL: https://github.com/nodejs/node/pull/28012
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-06-09 14:33:28 +05:30
Anatoli Papirovski
abf765e33c process: code cleanup for nextTick
Fix a few edge cases and non-obvious issues with nextTick:
1. Emit destroy hook in a try-finally rather than triggering
it before the callback runs.
2. Re-word comment for processPromiseRejections and make sure
it returns true in the rejectionHandled case too.
3. Small readability improvements.

PR-URL: https://github.com/nodejs/node/pull/28047
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-09 06:52:39 +02:00
Ruben Bridgewater
a23c2308a7 util: support AsyncGeneratorFunction in .inspect
This makes sure async generator functions are properly detected while
using `util.inspect`.

PR-URL: https://github.com/nodejs/node/pull/28056
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-08 19:10:36 -07:00
Luigi Pinca
d5577f0395 http: remove default 'timeout' listener on upgrade
Remove the default listener of the `'timeout'` event from the socket
before emitting the `'connect'` or `'upgrade'` event.

PR-URL: https://github.com/nodejs/node/pull/26030
Fixes: https://github.com/nodejs/node/issues/23857
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-08 13:35:37 +02:00
cjihrig
81a9c7201f
trace_events: respect inspect() depth
This commit causes the Tracing class to account for
util.inspect() depth.

PR-URL: https://github.com/nodejs/node/pull/28037
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-06-05 15:39:44 -04:00
Luigi Pinca
714a32c41f net: make writeAfterFIN() return false
If `false` is not returned a readable stream piped into the socket
might continue reading indefinitely until the process goes out of
memory.

PR-URL: https://github.com/nodejs/node/pull/27996
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-06-04 06:02:58 +02:00
Marcos Casagrande
df339bccf2 stream: convert string to Buffer when calling unshift(<string>)
`readable.unshift` can take a string as an argument, but that
string wasn't being converted to a Buffer, which caused a
<TypeError: Argument must be a buffer> in some cases. Also if a
string was passed, that string was coerced to utf8 encoding.

A second optional argument `encoding` was added to `unshift` to
fix the encoding issue.

Fixes: https://github.com/nodejs/node/issues/27192
PR-URL: https://github.com/nodejs/node/pull/27194
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-02 16:56:13 +02:00
himself65
aa00968255 child_process: move exports to bottom for consistent code style
PR-URL: https://github.com/nodejs/node/pull/27845
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2019-06-02 15:32:01 +02:00
Robert Nagy
c6f545a74a http: fix deferToConnect comments
PR-URL: https://github.com/nodejs/node/pull/27876
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-02 11:06:03 +02:00
Anatoli Papirovski
58b1fe7bd1 http: fix socketOnWrap edge cases
Properly handle prependListener wrapping on http server
socket, in addition to on and addListener.

PR-URL: https://github.com/nodejs/node/pull/27968
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-02 10:17:50 +02:00
cjihrig
f86100caf3
http2: respect inspect() depth
This commit causes Http2Stream and Http2Session to account
for inspect() depth.

PR-URL: https://github.com/nodejs/node/pull/27983
Fixes: https://github.com/nodejs/node/issues/27976
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-06-01 15:14:06 -04:00
Refael Ackermann
702331be90 lib: no need to strip BOM or shebang for scripts
PR-URL: https://github.com/nodejs/node/pull/27375
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-01 10:01:15 -04:00
Luigi Pinca
2a850cd066 http: call write callback even if there is no message body
Ensure that the callback of `OutgoingMessage.prototype.write()` is
called when `outgoingMessage._hasBody` is `false` (HEAD method, 204
status code, etc.).

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

PR-URL: https://github.com/nodejs/node/pull/27777
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-01 15:18:06 +02:00
Rich Trott
aa8b820aaa errors: create internal connResetException
Replace various instances of errors that use code ECONNRESET with a
single centralized factory function to create the errors.

(While making changes to _tls_wrap.js, this also takes the opportunity
to make trailing commas consistent on multi-line arrays. One had a
trailing comma and one didn't. This adds a traiiling comma to the one
that didn't.)

PR-URL: https://github.com/nodejs/node/pull/27953
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-05-31 21:21:19 +02:00
cjihrig
d05668d688
child_process: runtime deprecate _channel
This commit moves DEP0129 to a runtime deprecation.

PR-URL: https://github.com/nodejs/node/pull/27949
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-05-31 11:13:25 -04:00
cjihrig
14701e539c
module: runtime deprecate createRequireFromPath()
This commit moves DEP0130 to a runtime deprecation.

PR-URL: https://github.com/nodejs/node/pull/27951
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-05-31 11:09:53 -04:00
Alexander Avakov
f692299764 crypto: fix KeyObject handle type error message
Fix KeyObject handle type error message. Add test to cover KeyObject
ERR_INVALID_ARG_TYPE exception.

PR-URL: https://github.com/nodejs/node/pull/27904
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-05-30 15:37:02 +02:00
Yuriy Vasiyarov
a40aae8d1b src: export number_of_native_contexts and number_of_detached_contexts
export number_of_native_contexts and number_of_detached_contexts as
part of v8.getHeapStatistics()

PR-URL: https://github.com/nodejs/node/pull/27933
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-05-30 15:25:55 +02:00
Anna Henningsen
afb84744c6 stream: convert existing buffer when calling .setEncoding
Convert already-stored chunks when `.setEncoding()` is called
so that subsequent `data` events will receive decoded strings,
as they expect.

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

PR-URL: https://github.com/nodejs/node/pull/27936
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-05-30 14:35:29 +02:00