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

5697 Commits

Author SHA1 Message Date
Luigi Pinca
496d6023e0 net,stream: remove DuplexBase
`DuplexBase` was added to prevent the "no-half-open enforcer" from
being inherited by `net.Socket`. The main reason to use it instead
of `Duplex` was that it allowed to not copy the options object but
since commit 5e3f516 the options object is copyed anyway so it is
no longer useful.

PR-URL: https://github.com/nodejs/node/pull/19779
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-06 10:23:22 +02:00
cjihrig
a16d88d9e9
fs: expose copy-on-write flags for fs.copyFile()
This commit exposes the UV_FS_COPYFILE_FICLONE and
UV_FS_COPYFILE_FICLONE_FORCE flags added in libuv 1.20.0.

Fixes: https://github.com/nodejs/node/issues/19152
PR-URL: https://github.com/nodejs/node/pull/19759
Fixes: https://github.com/nodejs/node/issues/19152
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-05 23:11:20 -04:00
Ruben Bridgewater
b29c36b807
errors: make dns errors consistent
Right now the hostname could in some cases be missed, depending on
the libuv error number. This makes sure there the hostname is always
added, if available.

PR-URL: https://github.com/nodejs/node/pull/19754
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-05 19:29:02 +02:00
Ruben Bridgewater
22da2f731d
errors: make message non-enumerable
A error message should always be non-enumerable. This makes sure
that is true for dns errors as well. It also adds another check
in `common.expectsError` to make sure no other regressions are
introduced going forward.

Fixes #19716

PR-URL: https://github.com/nodejs/node/pull/19719
Fixes: https://github.com/nodejs/node/issues/19716
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-05 11:07:41 +02:00
Sergey Golovin
354849eeb5 url: replace "magic" numbers by constants
PR-URL: https://github.com/nodejs/node/pull/19300
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2018-04-05 08:38:46 +02:00
John-David Dalton
0876a0314d lib: ensure --check flag works with --require
PR-URL: https://github.com/nodejs/node/pull/19600
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-04-04 17:31:45 -07:00
Joyee Cheung
7d06761f83
errors: improve SystemError messages
This commit improves the SystemError messages by allowing user
to combine a custom message and the libuv error message. Also
since we now prefer use subclasses to construct the errors instead
of using `new errors.SystemError()` directly, this removes
the behavior of assigning a default error code `ERR_SYSTEM_ERROR`
to SystemError and requires the user to directly use the
`ERR_SYSTEM_ERROR` class to construct errors instead.

Also merges `makeNodeError` into the SystemError class definition
since that's the only place the function gets used and it seems
unnecessary to introduce another level of inheritance. SystemError
now directly inherits from Error instead of an intermmediate Error
class that inherits from Error.

Class hierarchy before this patch:

ERR_SOCKET_BUFFER_SIZE -> Error (use message formatted by SystemError)
ERR_SYSTEM_ERROR -> NodeError (temp) -> Error

After:

ERR_SOCKET_BUFFER_SIZE -> SystemError -> Error
ERR_TTY_INIT_FAILED -> SystemError -> Error
ERR_SYSTEM_ERROR -> SystemError -> Error

Error messages before this patch:

```
const dgram = require('dgram');
const socket = dgram.createSocket('udp4');
socket.setRecvBufferSize(8192);

// Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer
// size: Error [ERR_SYSTEM_ERROR]: bad file descriptor:
// EBADF [uv_recv_buffer_size]
//    at bufferSize (dgram.js:191:11)
//    at Socket.setRecvBufferSize (dgram.js:689:3)

const tty = require('tty');
new tty.WriteStream(1 << 30);
// Error [ERR_SYSTEM_ERROR]: invalid argument: EINVAL [uv_tty_init]
//     at new WriteStream (tty.js:84:11)
```

After:

```
const dgram = require('dgram');
const socket = dgram.createSocket('udp4');
socket.setRecvBufferSize(8192);

// SystemError [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer
// size: uv_recv_buffer_size returned EBADF (bad file descriptor)
//     at bufferSize (dgram.js:191:11)
//     at Socket.setRecvBufferSize (dgram.js:689:3)

const tty = require('tty');
new tty.WriteStream(1 << 30);
// SystemError [ERR_TTY_INIT_FAILED]: TTY initialization failed:
// uv_tty_init returned EINVAL (invalid argument)
//     at new WriteStream (tty.js:84:11)
```

PR-URL: https://github.com/nodejs/node/pull/19514
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-05 04:46:26 +08:00
Ruben Bridgewater
ceaeee0120
tty: add color support for more terminals
This adds support for a couple more terminals.

PR-URL: https://github.com/nodejs/node/pull/19730
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-04-04 15:14:05 +02:00
Ruben Bridgewater
1b715221b9
tty: add attribution for chalk
This adds attributions for the getColorDepth function as it got
inspired by https://github.com/chalk/supports-color and more sources.

PR-URL: https://github.com/nodejs/node/pull/19730
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-04-04 15:14:04 +02:00
Rich Trott
3d61e14704 buffer: shorten deprecation warning
Shorten the deprecation warning for Buffer constructor.

PR-URL: https://github.com/nodejs/node/pull/19741
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
2018-04-04 05:41:30 -07:00
Joyee Cheung
f7049a2006
fs: refactor stats array to be more generic
- Pass kFsStatsFieldsLength between JS and C++ instead of using the
  magic number 14
- Pass the global stats array to the completion callback of
  asynchronous FSReqWrap similar to how the stats arrays are passed
  to the FSReqPromise resolvers
- Abstract the stats converter and take an offset to compute the
  old stats in fs.watchFile
- Use templates in node::FillStatsArray and FSReqPromise in preparation
  for BigInt intergration
- Put the global stat array filler in node_internals.h because it is
  shared by node_file.cc and node_stat_watcher.cc

PR-URL: https://github.com/nodejs/node/pull/19714
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-04 15:25:59 +08:00
Teddy Katz
fdb35d8960
assert: ensure .rejects() disallows sync throws
This updates `assert.rejects()` to disallow any errors that are thrown
synchronously from the given function. Previously, throwing an error
would cause the same behavior as returning a rejected Promise.

Fixes: https://github.com/nodejs/node/issues/19646
PR-URL: https://github.com/nodejs/node/pull/19650
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-04-03 22:41:01 -04:00
XadillaX
b06f686f88 http: fix request when setHost is true
Fixes: https://github.com/nodejs/node/issues/19457

PR-URL: https://github.com/nodejs/node/pull/19502
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-04-03 15:43:40 -07:00
James M Snell
2ec6995555 perf_hooks: simplify perf_hooks
Remove the `performance.getEntries()` and `performance.clear*()`
variants and eliminate the accumulation of the global timeline
entries. The design of this particular bit of the API is a memory
leak and performance footgun. The `PerformanceObserver` API is
a better approach to consuming the data in a more transient way.

PR-URL: https://github.com/nodejs/node/pull/19563
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-04-03 13:57:41 -07:00
Michaël Zasso
34d988f122
vm: move options checks from C++ to JS
Also introduces stronger type validations for options passed to vm
functions.

PR-URL: https://github.com/nodejs/node/pull/19398
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-04-03 17:59:22 +02:00
Mike Kaufman
cd5f353405 lib: make isStackOverflowError() engine-agnostic
Assumption that stack overflow exception has name == "RangeError" is
v8-specific.  Updated logic to dynamically capture error name when
capturing error message.

PR-URL: https://github.com/nodejs/node/pull/19705
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-02 13:34:07 -07:00
Rich Trott
87972cd76f buffer: remove "new" from deprecation message
This change removes "new" as a description for `Buffer` construction
methods. They are arguably not "new" anymore and they certainly won't be
"new" anymore at some point.

PR-URL: https://github.com/nodejs/node/pull/19687
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Nikolai Vavilov <vvnicholas@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-01 21:08:54 -07:00
Guy Bedford
141be923f3 module: skip preserveSymlinks for main
PR-URL: https://github.com/nodejs/node/pull/19388
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-01 17:32:26 +02:00
Weijia Wang
254058109f tools: add 'spaced-comment' into eslint rules
PR-URL: https://github.com/nodejs/node/pull/19596
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2018-04-01 22:33:13 +08:00
punteek
07ba9141e4
vm: add support for import.meta to Module
Fixes: https://github.com/nodejs/node/issues/18570

PR-URL: https://github.com/nodejs/node/pull/19277
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
2018-03-31 19:55:50 -05:00
Gus Caplan
97ace04492
console: add table method
PR-URL: https://github.com/nodejs/node/pull/18137
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-03-30 19:41:41 -05:00
Anna Henningsen
923fb5cc18
net: track bytesWritten in C++ land
Move tracking of `socket.bytesWritten` to C++ land.

This makes it easier to provide this functionality for all
`StreamBase` instances, and in particular should keep working
when they have been 'consumed' in C++ in some way (e.g. for
the network sockets that are underlying to TLS or HTTP2 streams).

Also, this parallels `socket.bytesRead` a lot more now.

PR-URL: https://github.com/nodejs/node/pull/19551
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-30 14:20:40 +02:00
Matteo Collina
d37e59fa6a stream: fix backpressure when multiple sync
PR-URL: https://github.com/nodejs/node/pull/19613
Fixes: https://github.com/nodejs/node/issues/19601
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-03-30 12:13:59 +02:00
Bartosz Sosnowski
9bfe55e184 child_process: better spawn error message
Throw ERR_INVALID_ARG_VALUE when filename passed to spawn is empty.

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

PR-URL: https://github.com/nodejs/node/pull/19305
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-03-29 11:49:21 +02:00
Daniel Bevenius
e88cd882f5 lib: move Pipe/TCPConnectWrap to obj destructuring
This commit moves PipeConnectWrap and TCPConnectWrap into the object
destructuring assigments that already exist for pipe_wrap and tcp_wrap.

PR-URL: https://github.com/nodejs/node/pull/19611
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-29 07:31:33 +02:00
wangzengdi
108c176e8f lib: fix a typo in lib/timers "read through"
PR-URL: https://github.com/nodejs/node/pull/19666
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-03-28 20:10:19 -07:00
Anna Henningsen
e765257283 zlib,stream: use “official” util.types typechecks
The old variants have been deprecated since b20af8088a.

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

PR-URL: https://github.com/nodejs/node/pull/19602
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-28 16:21:56 -07:00
Daniel Bevenius
f2b10799ef lib: rename js source to lower snake_case
This commit renames all JavaScript source files in lib to lower
snake_case.

PR-URL: https://github.com/nodejs/node/pull/19556
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
2018-03-28 08:09:16 +02:00
Ben Noordhuis
9204a0db6e tls: runtime-deprecate tls.convertNPNProtocols()
Fixes: https://github.com/nodejs/node/issues/14602
PR-URL: https://github.com/nodejs/node/pull/19403
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2018-03-27 16:22:37 +02:00
Ben Noordhuis
5bfbe5ceae tls: drop NPN (next protocol negotiation) support
NPN has been superseded by ALPN.  Chrome and Firefox removed support for
NPN in 2016 and 2017 respectively to no ill effect.

Fixes: https://github.com/nodejs/node/issues/14602
PR-URL: https://github.com/nodejs/node/pull/19403
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2018-03-27 16:22:37 +02:00
Ashok
c2835e5e47
lib: merge stream code for http2 streams & net.Socket
Squashed from:

- lib: separate writev responsibilities from writeGeneric
- lib: fix calling of cb twice
- lib: extract streamId out of stream_base to caller
- lib: add symbols instead of methods to hide impl details
- lib: remove unneeded lines
- lib: use Object.assign instead of apply
- lib: rename mixin StreamBase to StreamSharedMethods
- lib: use stream shared funcs as top level instead of
  properties of prototypes
- lib: mv lib/internal/stream_shared_methods.js
  lib/internal/stream_base_commons.js
- lib: add comment for readability
- lib: refactor _writev in Http2Stream
- lib: rephrase comment
- lib: revert usage of const,let for perf reasons

PR-URL: https://github.com/nodejs/node/pull/19527
Refs: https://github.com/nodejs/node/issues/19060
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-03-27 12:57:23 +02:00
Anna Henningsen
d111d7b91c
stream: give error message if write() cb called twice
Otherwise, this condition would result in an error that just reads
`cb is not a function`, and which additionally could have lost
stack trace context through a `process.nextTick()` call.

PR-URL: https://github.com/nodejs/node/pull/19510
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-03-27 01:38:05 +01:00
Ruben Bridgewater
2e6dd93aaa
assert: fix diff color output
The color output was broken at some point and that was not detected
because it was not tested for properly so far. This makes sure the
colors work again and it adds a regression test as well.

PR-URL: https://github.com/nodejs/node/pull/19464
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-03-27 01:20:19 +01:00
Dan Kaplun
d49661bb80 console: don't swallow call stack exceeded errors
Fixes test/parallel/test-console-no-swallow-stack-exceeded.js

PR-URL: https://github.com/nodejs/node/pull/19423
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2018-03-25 20:03:17 -07:00
Anna Henningsen
34a948fc0b
lib: document nextTick queue internals
Make this code (a bit more) comprehensible by adding some
internals docs.

With diagrams and everything! 🎉

PR-URL: https://github.com/nodejs/node/pull/19469
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
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: Gus Caplan <me@gus.host>
2018-03-25 18:37:59 +02:00
Wes Todd
42d8ea0220
http: support server options on createServer
PR-URL: https://github.com/nodejs/node/pull/19461
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-25 11:51:32 +02:00
Ruben Bridgewater
1029dd3686
util: show Weak(Set|Map) entries in inspect
This adds support for WeakMap and WeakSet entries in `util.inspect`.
The output is limited to a maximum entry length of `maxArrayLength`.

PR-URL: https://github.com/nodejs/node/pull/19259
Fixes: https://github.com/nodejs/node/issues/19001:
Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-25 03:21:27 +02:00
Ruben Bridgewater
0fbd4b1d02
util: improve iterator inspect output
1) So far extra keys on an (Set|Map)Iterator were ignored. Those
   will now be visible.
2) Improve the performance of showing (Set|Map)Iterator by using
   the cloned iterator instead of copying all entries first.
3) So far the output was strictly limited to up to 100 entries.
   The limit will now depend on `maxArrayLength` instead (that
   default is set to 100 as well) and the output indicates that
   more entries exist than visible.

PR-URL: https://github.com/nodejs/node/pull/19259
Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-25 03:21:26 +02:00
Tobias Nießen
eeb1b9dcb7
Revert "process: add more version properties to release"
This reverts commit 982e3bdb1f. It is
believed that the original PR should not have landed as it is as the
implemented and exposed API has a variety of flaws.

PR-URL: https://github.com/nodejs/node/pull/19577
Refs: https://github.com/nodejs/node/pull/19438
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2018-03-25 03:18:56 +02:00
Ruben Bridgewater
a1c96f8e07
assert: improve assert.throws
This switches the assert.throws output to the one used in strict mode
if a error object is used for comparison. From now on it will show
the complete difference between two objects instead of only showing
the first failing property.

It also fixes detecting properties with a undefined value and fails
in case the thrown error does not contain the value at all.

PR-URL: https://github.com/nodejs/node/pull/19463
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-25 03:10:15 +02:00
Ruben Bridgewater
28e4e43e51
errors: make input mandatory
Using ERR_INVALID_ARG_TYPE will now require the received value as
well. This makes sure the errors are always expressive. It also
drops support for using an array as name argument.

PR-URL: https://github.com/nodejs/node/pull/19445
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-03-25 03:02:24 +02:00
Ruben Bridgewater
b38c81cb44
lib: improve error handling
This improves the error handling for a couple cases where the
received value would not have been handled so far or where the name
is wrong etc.

PR-URL: https://github.com/nodejs/node/pull/19445
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-03-25 03:01:45 +02:00
Ruben Bridgewater
acc3c770e7
fs: fix error handling
Right now there are multiple cases where the validated entry would
not be returned or a wrong error is thrown. This fixes both cases.

PR-URL: https://github.com/nodejs/node/pull/19445
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-03-25 01:45:40 +01:00
Ruben Bridgewater
058e7fb8e6
process: fix error handling
This makes sure the proper error is returned. Right now the error
is not specific enough.

PR-URL: https://github.com/nodejs/node/pull/19445
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-03-25 01:45:40 +01:00
Ruben Bridgewater
333adf61eb
crypto: fix error handling
This fixes multiple cases where the wrong error was returned in
case of e.g. a overflow / wrong type.

PR-URL: https://github.com/nodejs/node/pull/19445
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-03-25 01:45:39 +01:00
Ruben Bridgewater
c1278e5329
lib,test: minor refactoring
This refactors a couple tests to have upper case first characters
in comments and to use `input` instead of `i`.
It also adds a few TODOs and rewrites a few lines to use default
arguments and to prevent function recreation when unnecessary.

PR-URL: https://github.com/nodejs/node/pull/19445
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-03-25 01:45:38 +01:00
Ruben Bridgewater
c6b6c92185
lib: always show ERR_INVALID_ARG_TYPE received part
This makes a effort to make sure all of these errors will actually
also show the received input.
On top of that it refactors a few tests for better maintainability.
It will also change the returned type to always be a simple typeof
instead of special handling null.

PR-URL: https://github.com/nodejs/node/pull/19445
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-03-25 01:45:37 +01:00
Benjamin Gruenbaum
e06ad5faf9 fs: use encoding in readFile
Use the encoding parameter passed to fsPromises.readFile if it is
passed. Currently the encoding parameter is ignored in fsPromises.

PR-URL: https://github.com/nodejs/node/pull/19296
Fixes: https://github.com/nodejs/node/issues/19286
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
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>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
2018-03-24 18:23:08 +01:00
Ruben Bridgewater
f4e5f969ba buffer: improve write(U)Int functions
This improves the performance of some write functions by around 5-15%.

PR-URL: https://github.com/nodejs/node/pull/19289
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-24 16:50:01 +01:00
Rich Trott
5e00a013eb lib,test: lint fixes for linter upgrade
ESLint 4.19.1 fixes some bugs in rules. These changes prepare us for the
upgrade.

PR-URL: https://github.com/nodejs/node/pull/19528
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-24 04:11:40 -07:00