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

7870 Commits

Author SHA1 Message Date
Ruben Bridgewater
539df7387d
readline: improve getStringWidth()
1. Simplify the getStringWidth function used by Intl builds by removing
   dead code (the options were unused) and by refactoring the logic.
2. Improve the getStringWidth unicode handling used by non-Intl builds.
   The getStringWidth function returned the wrong width for multiple
   inputs. It's now improved by supporting various zero width characters
   and more full width characters.

PR-URL: https://github.com/nodejs/node/pull/31112
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-01-10 09:11:51 +01:00
Ruben Bridgewater
b52bf60518
readline,repl: improve history up/previous
Reaching the history end caused the last entry to be persistent.
That way there's no actualy feedback to the user that the history
end is reached. Instead, visualize the original input line and keep
the history index at the history end in case the user wants to go
back again.

PR-URL: https://github.com/nodejs/node/pull/31112
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-01-10 09:11:50 +01:00
Ruben Bridgewater
d449c505f3
readline,repl: skip history entries identical to the current line
Skip history entries that are identical to the currently visible line
to improve the user experience.

PR-URL: https://github.com/nodejs/node/pull/31112
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-01-10 09:11:48 +01:00
Ruben Bridgewater
625a0ec5e1
readline,repl: add substring based history search
This improves the current history search feature by adding substring
based history search similar to ZSH. In case the `UP` or `DOWN`
buttons are pressed after writing a few characters, the start string
up to the current cursor is used to search the history.

All other history features work exactly as they used to.

PR-URL: https://github.com/nodejs/node/pull/31112
Fixes: https://github.com/nodejs/node/issues/28437
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-01-10 09:11:47 +01:00
Ruben Bridgewater
07c55bb81f
repl: improve preview length calculation
The preview had an off by one error in case colors where deactivated
and did not take fullwidth unicode characters into account when
displaying the preview.

PR-URL: https://github.com/nodejs/node/pull/31112
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-01-10 09:11:46 +01:00
Bryan English
73a9c37307 fs: use async writeFile in FileHandle#appendFile
When operating on a FileHandle, the file has already been opened with
the flag given as an option to fs.promises.open(). This means defaulting
to 'a' has no effect here, and FileHandle#appendFile turns out to
exactly be an alias of writeFile. This is now explicit, saving a stack
frame, object copy and assignment.

PR-URL: https://github.com/nodejs/node/pull/31235
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
2020-01-09 16:48:55 -08:00
antsmartian
aff6fffec5 stream: clean up definition using defineProperties
PR-URL: https://github.com/nodejs/node/pull/31236
Refs: https://github.com/nodejs/node/pull/31187
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-08 21:38:02 -08:00
Sebastien Ahkrin
607be0c78a stream: replace Function.prototype with primordial
PR-URL: https://github.com/nodejs/node/pull/31204
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2020-01-08 06:10:11 -08:00
cjihrig
ba98d9ab2c
lib,tools,test: remove custom number-isnan rule
This commit removes the custom number-isnan ESLint rule in
favor of the no-restricted-syntax rule. It also applies the
rule across the entire codebase, instead of just the test/
directory.

PR-URL: https://github.com/nodejs/node/pull/31211
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-08 00:22:25 -05:00
Sebastien Ahkrin
a494d12723 lib: add RegExp primordials
PR-URL: https://github.com/nodejs/node/pull/31208
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-01-07 19:26:15 -08:00
cjihrig
b8922e8924
wasi: improve use of primordials
PR-URL: https://github.com/nodejs/node/pull/31212
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-07 21:49:20 -05:00
Sebastien Ahkrin
92cef79779 lib: replace Float32Array global by the primordials
PR-URL: https://github.com/nodejs/node/pull/31195
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-07 15:09:59 -08:00
Sebastien Ahkrin
4f51c12d41 lib: replace BigUInt64Array global by the primordials
PR-URL: https://github.com/nodejs/node/pull/31194
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-07 13:15:40 -08:00
Robert Nagy
b9e6c1bcb2
stream: sync stream unpipe resume
pipe() ondata should not control flow state if cleaned up.

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

PR-URL: https://github.com/nodejs/node/pull/31191
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-07 16:00:00 +01:00
Guy Bedford
405e7b4557 module: logical conditional exports ordering
PR-URL: https://github.com/nodejs/node/pull/31008
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
2020-01-07 06:14:19 +02:00
Geoffrey Booth
2551a21553 module: loader getSource, getFormat, transform hooks
PR-URL: https://github.com/nodejs/node/pull/30986
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
2020-01-07 01:31:05 +02:00
Anna Henningsen
20fd12310f lib: move initialization of APIs for changing process state
Whether these APIs should be available for Node.js instances
semantically depends on whether the current Node.js instance
was assigned ownership of process-wide state, and not whether
it refers to the main thread or not.

PR-URL: https://github.com/nodejs/node/pull/31172
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
2020-01-06 06:54:17 -08:00
himself65
714eb919cc wasi: refactor destructuring object on constructor
PR-URL: https://github.com/nodejs/node/pull/31185
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2020-01-05 22:12:44 -08:00
Robert Nagy
66f4e4edcb stream: do not emit 'end' after 'error'
Refs: https://github.com/nodejs/node/issues/6083

PR-URL: https://github.com/nodejs/node/pull/31182
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-05 22:10:19 -08:00
ZYSzys
66310c2b78 http2: set default enableConnectProtocol to 0
PR-URL: https://github.com/nodejs/node/pull/31174
Refs: https://tools.ietf.org/html/rfc8441#section-9.1
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-05 18:16:20 -08:00
Robert Nagy
75b30c606c stream: emit 'error' asynchronously
errorOrDestroy emits 'error' synchronously due to
compat reasons. However, it should be possible to
use correct async behaviour for new code.

PR-URL: https://github.com/nodejs/node/pull/29744
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-04 16:20:45 -08:00
Sebastien Ahkrin
9085c03806 lib: replace Map global by the primordials
PR-URL: https://github.com/nodejs/node/pull/31155
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-01-04 14:56:52 -08:00
Sebastien Ahkrin
c9b93e2344 lib: replace use of Error with primordials
PR-URL: https://github.com/nodejs/node/pull/31163
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-01-04 14:50:18 -08:00
Sebastien Ahkrin
256c9a43f4 lib: replace Set global by the primordials
PR-URL: https://github.com/nodejs/node/pull/31154
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-01-04 12:41:09 -08:00
Sebastien Ahkrin
5dc55ede67 lib: replace WeakSet global by the primordials
PR-URL: https://github.com/nodejs/node/pull/31157
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-01-04 12:35:45 -08:00
Sebastien Ahkrin
f509aaa7fa lib: replace WeakMap global by the primordials
PR-URL: https://github.com/nodejs/node/pull/31158
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-01-04 12:28:29 -08:00
Sebastien Ahkrin
e56840368b lib: replace Set.prototype with SetPrototype primordial
PR-URL: https://github.com/nodejs/node/pull/31161
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
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: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-01-04 10:51:52 -08:00
Kamat, Trivikram
bf6b39dc9f perf_hooks: use for...of
PR-URL: https://github.com/nodejs/node/pull/31049
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-04 09:55:46 -08:00
Ruben Bridgewater
904a81d235 lib: do not catch user errors
The API caught errors from inside of the users passed through callback.
This never caused any issues, since this API is only used internally.
Otherwise it would have potentially hidden bugs in user code.

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

PR-URL: https://github.com/nodejs/node/pull/31159
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-01-04 09:04:37 -08:00
Vighnesh Raut
fa946983cc https: prevent options object from being mutated
Previously, when passing options object to the agent.createConnection
method, the same options object got modified within the method. Now,
any modification will happen on only a copy of the object.

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

PR-URL: https://github.com/nodejs/node/pull/31151
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-03 20:09:27 -08:00
Ruben Bridgewater
84c426cb60
repl: properly handle repl.repl
The repl property is set so that it's possible to inspect the
instances own properties during runtime. This was never tested and
it was also only exported in case the instance was started with
`.start()` instead of using the constructor directly. In case that
more than a single instance was created, all instances got access
to the first instance.

From now on the repl property is only exported in case the repl is
starte as standalone program.

PR-URL: https://github.com/nodejs/node/pull/30981
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-03 16:37:38 +01:00
Anna Henningsen
e65bed1b7e
child_process: create proper public API for channel
Instead of exposing the C++ bindings object as `subprocess.channel`
or `process.channel`, provide the “control” object that was
previously used internally as the public-facing variant of it.

This should be better than returning the raw pipe object, and
matches the original intention (when the `channel` property was
first added) of providing a proper way to `.ref()` or `.unref()`
the channel.

PR-URL: https://github.com/nodejs/node/pull/30165
Refs: https://github.com/nodejs/node/pull/9322
Refs: https://github.com/nodejs/node/issues/9313
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-01-03 16:32:36 +01:00
telenord
6450f36dd4
http: http_outgoing rename var to let and const
PR-URL: https://github.com/nodejs/node/pull/30284
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-01-03 15:44:38 +01:00
Thomas
a25a628452
esm: better error message for unsupported URL
The default ESM loader supports only file and data URLs.
This PR adds better error message for it.

PR-URL: https://github.com/nodejs/node/pull/31129
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2020-01-03 15:33:16 +01:00
Robert Nagy
4bec6d13f9
stream: enable autoDestroy by default
PR-URL: https://github.com/nodejs/node/pull/30623
Refs: https://github.com/nodejs/node/issues/30621
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-03 01:49:10 +01:00
Robert Nagy
7c70dbb986
http: free listeners on free sockets
Reduced memory usage by ensuring free sockets don't have extra
listeners while in the pool.

PR-URL: https://github.com/nodejs/node/pull/29259
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>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2020-01-03 01:36:15 +01:00
bcoe
9cdda60081
errors: support prepareSourceMap with source-maps
Adds support for Error.prepareStackTrace override, when
--enable-source-maps is set.

PR-URL: https://github.com/nodejs/node/pull/31143
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-01-02 15:07:38 -08:00
Ruben Bridgewater
7babffbe60
util: improve prototype inspection using inspect() and showHidden
The fast path for the prototype inspection had a bug that caused some
prototype properties to be skipped that should in fact be inspected.

PR-URL: https://github.com/nodejs/node/pull/31113
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-02 18:02:00 +01:00
Guy Bedford
c7f328f0df
module: unflag resolve self
PR-URL: https://github.com/nodejs/node/pull/31002
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2020-01-02 17:53:47 +01:00
antsmartian
2257e80902
stream: group all properties using defineProperties
PR-URL: https://github.com/nodejs/node/pull/31144
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-01-02 17:32:58 +01:00
Ruben Bridgewater
e33f773d4f
assert: implement assert.match() and assert.doesNotMatch()
This adds a new functionality to the assertion module: a dedicated
check for regular expressions. So far it's possible to use
`assert.ok(regexp.test(string))`. This is not ideal though when it
comes to the error message, since it's not possible to know how
either of the input values look like. It's just known that the
assertion failed.
This allows to pass through the regular expression and the input
string. The string is then matched against the regular expression
and reports a expressive error message in case of a failure.

PR-URL: https://github.com/nodejs/node/pull/30929
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2020-01-01 18:44:31 +01:00
Robert Nagy
a1d307fc32
http2: make HTTP2ServerResponse more streams compliant
HTTP2ServerResponse.write would behave differently than
both http1 and streams. This PR makes it more compliant
with stream.Writable behaviour.

PR-URL: https://github.com/nodejs/node/pull/30964
Refs: https://github.com/nodejs/node/issues/29529
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-01 18:40:12 +01:00
Bradley Farias
baa3621bb1 esm: empty ext from pkg type/main doesnt affect format
This ensures files with unknown extensions like foo.bar are not
loaded as CJS/ESM when imported as a main entry point and makes
sure that those files would maintain the same format even if loaded
after the main entrypoint.

PR-URL: https://github.com/nodejs/node/pull/31021
Reviewed-By: Guy Bedford <guybedford@gmail.com>
2019-12-31 09:11:11 -06:00
Robert Nagy
e66c4deda8 stream: invoke buffered write callbacks on error
Buffered write callbacks were only invoked upon
error if `autoDestroy` was invoked.

PR-URL: https://github.com/nodejs/node/pull/30596
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-30 21:33:49 -08:00
Kamat, Trivikram
0a958f442c zlib: use for...of
PR-URL: https://github.com/nodejs/node/pull/31051
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-30 21:24:08 -08:00
Guy Bedford
8a96d05ec7 module: self resolve bug fix and esm ordering
PR-URL: https://github.com/nodejs/node/pull/31009
Reviewed-By: Jan Krems <jan.krems@gmail.com>
2019-12-29 11:17:21 -05:00
cjihrig
3cd77805fe fs: use consistent defaults in sync stat functions
This commit updates the default options used by statSync(),
lstatSync(), and fstatSync() to be identical to the defaults
used by the callback- and Promise-based versions.

PR-URL: https://github.com/nodejs/node/pull/31097
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-12-29 07:47:01 -08:00
kresimirfranin
a412a97a73 lib: replace var with let/const
PR-URL: https://github.com/nodejs/node/pull/30394
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-12-28 20:19:55 +05:30
Anna Henningsen
0e89b64d66
zlib: allow writes after readable 'end' to finish
Call the callback for writes that occur after the stream is closed.
This also requires changes to the code to not call `.destroy()`
on the stream in `.on('end')`, and to ignore chunks written
afterwards.

Previously, these writes would just queue up silently, as their
`_write()` callback would never have been called.

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

PR-URL: https://github.com/nodejs/node/pull/31082
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-12-27 02:13:44 +01:00
cjihrig
befff8fa60
repl: use public getCursorPos()
_getCursorPos() recently became public API. This commit updates
the remaining uses of _getCursorPos() to use the public API.

PR-URL: https://github.com/nodejs/node/pull/31091
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-12-25 20:12:23 -05:00
Joyee Cheung
403c84a1cf
src: port --bash-completion to C++
So that it gets handle earlier and faster during the bootstrap
process.

Drive-by fixes:

- Remove `[has_eval_string]` and `[ssl_openssl_cert_store]` from
  the completion output
- Set `kProfProcess` execution mode for `--prof-process` instead
  of `kPrintBashProcess` which is removed in this patch.
- Append new line to the end of the output of --bash-completion

PR-URL: https://github.com/nodejs/node/pull/25901
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-25 22:15:41 +01:00
Robert Nagy
c852f7e2ac stream: pipeline should use req.abort() to destroy response
destroy(err) on http response will propagate the error to the
request causing 'error' to be unexpectedly emitted. Furthermore,
response.destroy() unlike request.abort() does not _dump buffered
data.

Fixes a breaking change introduced in 648088289d.

Prefer res.req.abort() over res.destroy() until this situation is
clarified.

Fixes: https://github.com/nodejs/node/issues/31029
Refs: 648088289d

PR-URL: https://github.com/nodejs/node/pull/31054
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-12-25 12:50:30 -08:00
Anatoli Papirovski
1fab8a9297
timers: fix refresh for expired timers
Expired timers were not being refresh correctly and
would always act as unrefed if refresh was called.

PR-URL: https://github.com/nodejs/node/pull/27345
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-25 12:45:24 +01:00
Anatoli Papirovski
0b89761d6d
timers: do less work in insert
Most of the code in insert is only applicable to scheduling
non-timers or re-scheduling timers. We can skip most of it
in the case of setTimeout, setInterval & setUnrefTimeout.

PR-URL: https://github.com/nodejs/node/pull/27345
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-25 12:45:23 +01:00
Denys Otrishko
f8d7e2216e
tls: add PSK support
Add the `pskCallback` client/server option, which resolves an identity
or identity hint to a pre-shared key.

Add the `pskIdentityHint` server option to set the identity hint for the
ServerKeyExchange message.

Co-authored-by: Chris Osborn <chris.osborn@sitelier.com>
Co-authored-by: stephank <gh@stephank.nl>
Co-authored-by: Taylor Zane Glaeser <tzglaeser@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/23188
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-12-25 12:24:42 +01:00
Robert Nagy
3d47c8592d
stream: reset flowing state if no 'readable' or 'data' listeners
If we don't have any 'readable' or 'data' listeners and we are
not about to resume. Then reset flowing state to initial null state.

PR-URL: https://github.com/nodejs/node/pull/31036
Fixes: https://github.com/nodejs/node/issues/24474
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-25 12:12:59 +01:00
Robert Nagy
cd6b00df33
stream: simplify isBuf
PR-URL: https://github.com/nodejs/node/pull/31067
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
2019-12-25 12:05:33 +01:00
A. Volgin
643241ae3f
dgram: test to add and to drop specific membership
Test of addSourceSpecificMembership and dropSourceSpecificMembership
for correct arguments with sourceAddress, groupAddress.

PR-URL: https://github.com/nodejs/node/pull/31047
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-12-25 11:58:29 +01:00
Ruben Bridgewater
489e77c119
util: add (typed) array length to the default output
Align the inspect output with the one used in the Chrome dev tools.
A recent survey outlined that most users prefer to see the number
of set and map entries. This should count as well for array sizes.
The size is only added to regular arrays in case the constructor is
not the default constructor.
Typed arrays always indicate their size.

PR-URL: https://github.com/nodejs/node/pull/31027
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
2019-12-25 11:19:43 +01:00
Ruben Bridgewater
b45eeee017
readline: set null as callback return in case there's no error
The cursor move functions accept a callback. It was possible that
`undefined` was returned in case there was no error instead of null.

PR-URL: https://github.com/nodejs/node/pull/31006
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-25 11:17:31 +01:00
Ruben Bridgewater
b768e84794
readline: small refactoring
This just removes some redundant work and some other small things.

PR-URL: https://github.com/nodejs/node/pull/31006
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-25 11:17:31 +01:00
Ruben Bridgewater
9e4349e797
repl: implement reverse search
Add a reverse search that works similar to the ZSH one. It is
triggered with <ctrl> + r and <ctrl> + s. It skips duplicated history
entries and works with multiline statements. Matching entries indicate
the search parameter with an underscore and cancelling with <ctrl> + c
or escape brings back the original line.
Multiple matches in a single history entry work as well and are
matched in the order of the current search direction. The cursor is
positioned at the current match position of the history entry.
Changing the direction immediately checks for the next entry in the
expected direction from the current position on.
Entries are accepted as soon any button is pressed that doesn't
correspond with the reverse search.
The behavior is deactivated for simple terminals. They do not support
most ANSI escape codes that are necessary for this feature.

PR-URL: https://github.com/nodejs/node/pull/31006
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-25 11:16:38 +01:00
Ruben Bridgewater
ca9f12bf83
repl: fix preview of lines that exceed the terminal columns
This adds support for very long input lines to still display the
input preview correct.

PR-URL: https://github.com/nodejs/node/pull/31006
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-25 11:15:03 +01:00
Ruben Bridgewater
a03458396b
util: add colors to debuglog()
This adds colors to the passed through arguments in case the stream
supports colors. The PID will also be highlighted.

PR-URL: https://github.com/nodejs/node/pull/30930
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-25 11:09:16 +01:00
Denys Otrishko
be3c7aceba
http2: wait for session socket writable end on close/destroy
This slightly alters the behaviour of session close by first using
.end() on a session socket to finish writing the data and only then
calls .destroy() to make sure the Readable side is closed. This allows
the socket to finish transmitting data, receive proper FIN packet and
avoid ECONNRESET errors upon graceful close.

onStreamClose now directly calls stream.destroy() instead of
kMaybeDestroy because the latter will first check that the stream has
writableFinished set. And that may not be true as we have just
(synchronously) called .end() on the stream if it was not closed and
that doesn't give it enough time to finish. Furthermore there is no
point in waiting for 'finish' as the other party have already closed the
stream and we won't be able to write anyway.

This also changes a few tests to correctly handle graceful session
close. This includes:
* not reading request data (on client side)
* not reading push stream data (on client side)
* relying on socket.destroy() (on client) to finish server session
  due to the destroy of the socket without closing the server session.
  As the goaway itself is *not* a session close.

Added few 'close' event mustCall checks.

PR-URL: https://github.com/nodejs/node/pull/30854
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-25 11:07:04 +01:00
Denys Otrishko
a8c2c667ce
http2: wait for session to finish writing before destroy
PR-URL: https://github.com/nodejs/node/pull/30854
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-25 11:07:02 +01:00
Rich Trott
9c566e6289 doc,vm,test: remove _sandbox_ from vm documentation
The vm documentation uses the word _sandbox_ but has a significant
disclaimer about how that should not be interpreted to connote security
guarantees. Remove the term "sandbox" from documentation. As a result,
some code and tests also need to change.

PR-URL: https://github.com/nodejs/node/pull/31057
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-12-24 16:14:05 -08:00
Anna Henningsen
db109e85d6
lib: further simplify assertions in vm/module
Refs: https://github.com/nodejs/node/pull/30755

PR-URL: https://github.com/nodejs/node/pull/30815
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-12-23 13:06:29 -05:00
Matteo Collina
38a593b0f3 events: add EventEmitter.on to async iterate over events
Fixes: https://github.com/nodejs/node/issues/27847
PR-URL: https://github.com/nodejs/node/pull/27994
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-23 09:29:01 +01:00
David Newman
312f3086c2 lib: improve spelling and grammar in comment
PR-URL: https://github.com/nodejs/node/pull/31026
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2019-12-21 21:29:32 -08:00
Trivikram Kamat
c68ecee6a9 dgram: use for...of
PR-URL: https://github.com/nodejs/node/pull/30999
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-20 07:35:39 -08:00
Joyee Cheung
c63d511c13
bootstrap: use different scripts to setup different configurations
This patch splits the handling of `isMainThread` and
`ownsProcessState` from conditionals in
`lib/internal/bootstrap/node.js` into different scripts under
`lib/internal/bootstrap/switches/`, and call them accordingly
from C++ after `node.js` is run.

This:

- Creates a common denominator of the main thread and the worker
  thread bootstrap that can be snapshotted and shared by
  both.
- Makes it possible to override the configurations on-the-fly.

PR-URL: https://github.com/nodejs/node/pull/30862
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2019-12-20 22:10:13 +08:00
Ruben Bridgewater
ac2fc0dd5f
errors: improve ERR_INVALID_ARG_TYPE
ERR_INVALID_ARG_TYPE is the most common error used throughout the
code base. This improves the error message by providing more details
to the user and by indicating more precisely which values are allowed
ones and which ones are not.

It adds the actual input to the error message in case it's a primitive.
If it's a class instance, it'll print the class name instead of
"object" and "falsy" or similar entries are not named "type" anymore.

PR-URL: https://github.com/nodejs/node/pull/29675
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-20 03:10:13 +01:00
Ruben Bridgewater
fc28761d77
buffer: improve .from() error details
This makes sure the original input is passed to the error in case
no matching inputs are found. Instead of passing along all values,
only valid or possibliy valid values are passed through. That way
invalid values end up in the error case with the original input.

PR-URL: https://github.com/nodejs/node/pull/29675
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-20 03:10:12 +01:00
Gerhard Stoebich
fcd4c2e37d
events: allow monitoring error events
Installing an error listener has a side effect that emitted errors are
considered as handled. This is quite bad for monitoring/logging tools
which tend to be interested in errors but don't want to cause side
effects like swallow an exception.

There are some workarounds in the wild like monkey patching emit or
remit the error if monitoring tool detects that it is the only listener
but this is error prone and risky.

This PR allows to install a listener to monitor errors with the side
effect to consume the error. To avoid conflicts with other events it
exports a symbol on EventEmitter which owns this special meaning.

Refs: https://github.com/open-telemetry/opentelemetry-js/issues/225

PR-URL: https://github.com/nodejs/node/pull/30932
Refs: https://github.com/open-telemetry/opentelemetry-js/issues/225
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-20 01:42:51 +01:00
Robert Nagy
20d009d2fd
stream: pipe should not swallow error
PR-URL: https://github.com/nodejs/node/pull/30993
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-20 01:38:35 +01:00
Robert Nagy
2b9847c637 fs: allow overriding fs for streams
Allow overriding open, write, and close when using createReadStream()
and createWriteStream().

PR-URL: https://github.com/nodejs/node/pull/29083
Refs: https://github.com/nodejs/node/issues/29050
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-18 07:03:37 -08:00
cjihrig
2b06166c76 doc,lib,src,test: rename WASI CLI flag
The WASI API has moved from preview0 to preview1. This commit
updates the CLI flag accordingly.

PR-URL: https://github.com/nodejs/node/pull/30980
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-17 17:35:12 -08:00
Soar
145116b3a1 assert: use for...of
Refs: #30960

PR-URL: https://github.com/nodejs/node/pull/30983
Refs: https://github.com/nodejs/node/pull/30960
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-12-17 17:33:12 -08:00
Trivikram Kamat
ddedf8eaac http: use for...of in http library code
PR-URL: https://github.com/nodejs/node/pull/30958
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-12-17 10:18:00 -08:00
Trivikram Kamat
7f536f2455 tls: for...of in _tls_common.js
PR-URL: https://github.com/nodejs/node/pull/30961
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-17 08:11:13 -05:00
Anatoli Papirovski
503900b463 async_hooks: ensure proper handling in runInAsyncScope
We should never try to manually run emitAfter in case of an error,
the exception handler will do it for us, if we're going to recover.

PR-URL: https://github.com/nodejs/node/pull/30965
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-16 21:59:50 -08:00
cjihrig
efb908409e wasi: require CLI flag to require() wasi module
This commit ensures that the WASI module cannot be require()'ed
without a CLI flag while the module is still experimental.

This fixes a regression from
https://github.com/nodejs/node/pull/30778.

PR-URL: https://github.com/nodejs/node/pull/30963
Reviewed-By: Anna Henningsen <anna@addaleax.net>
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: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
2019-12-17 06:02:04 +01:00
Trivikram Kamat
ce49f90e14 stream: use for...of
PR-URL: https://github.com/nodejs/node/pull/30960
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-16 18:18:50 -05:00
Antoine du HAMEL
024b658831
process: refs --unhandled-rejections documentation in warning message
Refs: https://github.com/nodejs/node/issues/20392

PR-URL: https://github.com/nodejs/node/pull/30564
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-16 11:23:47 +01:00
Jeremy Albright
a68729cf3d
readline: promote _getCursorPos to public api
Alias _getCursorPos() = getCursorPos() for backwards
compatibility.

Refs: https://github.com/nodejs/node/issues/30347

PR-URL: https://github.com/nodejs/node/pull/30687
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-12-16 11:22:25 +01:00
Rongjian Zhang
81e3bcae65
process: fix promise catching
Fixes: https://github.com/nodejs/node/issues/30953

PR-URL: https://github.com/nodejs/node/pull/30957
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-16 11:14:26 +01:00
Sebastien Ahkrin
437b6d5d4f
lib: replace Symbol.species by SymbolSpecies
PR-URL: https://github.com/nodejs/node/pull/30950
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-16 09:48:16 +01:00
Sebastien Ahkrin
48d986c40f
lib: replace Symbol.hasInstance by SymbolHasInstance
PR-URL: https://github.com/nodejs/node/pull/30948
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: David Carlier <devnexen@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-16 09:47:30 +01:00
Sebastien Ahkrin
593240d1a1
lib: replace Symbol.asyncIterator by SymbolAsyncIterator
PR-URL: https://github.com/nodejs/node/pull/30947
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-16 09:23:50 +01:00
Michaël Zasso
7e5bf80fd1
lib: enforce use of Promise from primordials
PR-URL: https://github.com/nodejs/node/pull/30936
Refs: https://github.com/nodejs/node/issues/30697
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-12-16 08:40:14 +01:00
Sebastien Ahkrin
c88ace4fc3
v8: use of TypedArray constructors from primordials
PR-URL: https://github.com/nodejs/node/pull/30740
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-16 08:33:41 +01:00
Sebastien Ahkrin
e9f2d7cff7
lib: add TypedArray constructors to primordials
PR-URL: https://github.com/nodejs/node/pull/30740
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-16 08:33:20 +01:00
Ruben Bridgewater
2986068c5a
repl: fix preview bug in case of long lines
This addresses an issue that is caused by lines that exceed the
current window columns. That would cause the preview to confuse the
REPL. This is meant as hot fix. The preview should be able to handle
these cases appropriately as well later on.

PR-URL: https://github.com/nodejs/node/pull/30907
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-15 16:26:35 +01:00
Ruben Bridgewater
21ecaa47ee
repl: add completion preview
This improves the already existing preview functionality by also
checking for the input completion. In case there's only a single
completion, it will automatically be visible to the user in grey.
If colors are deactivated, it will be visible as comment.

This also changes some keys by automatically accepting the preview
by moving the cursor behind the current input end.

PR-URL: https://github.com/nodejs/node/pull/30907
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-15 16:26:35 +01:00
Ruben Bridgewater
6c542d1c26
repl: improve completion
This improves the completion output by removing the nested special
handling. It never fully worked as expected and required a lot of
hacks to even keep it working halfway reliable. Our tests did not
cover syntax errors though and those can not be handled by this
implementation. Those break the layout and confuse the REPL.

Besides that the completion now also works in case the current line
has leading whitespace.

Also improve the error output in case the completion fails.

PR-URL: https://github.com/nodejs/node/pull/30907
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-15 16:24:00 +01:00
Ruben Bridgewater
af5c8af5e9
repl,readline: refactor for simplicity
This just refactors code without changing the behavior. Especially
the REPL code is difficult to read and deeply indented. This reduces
the indentation to improve that.

PR-URL: https://github.com/nodejs/node/pull/30907
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-15 16:23:59 +01:00
Ruben Bridgewater
52e5eb7e52
repl,readline: refactor common code
This renames some variables for clarity and moves the common substring
part into a shared file. One algorithm was more efficient than the
other but the functionality itself was identical.

PR-URL: https://github.com/nodejs/node/pull/30907
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-15 16:23:59 +01:00
Ruben Bridgewater
8f9cd3841d
readline: update ansi-regex
This updates the used regular expression to the latest version.
It includes a number of additional escape codes.

PR-URL: https://github.com/nodejs/node/pull/30907
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-15 16:23:59 +01:00
Ruben Bridgewater
1aab392cf3
repl: simplify code
This simplifies some repl code and removes a code branch that is
unreachable.

PR-URL: https://github.com/nodejs/node/pull/30907
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-15 16:23:53 +01:00
Ruben Bridgewater
37f6a42f72
repl: simplify repl autocompletion
This simplifies calling `filteredOwnPropertyNames()`. The context
is not used in that function, so there's no need to call the function
as such.

PR-URL: https://github.com/nodejs/node/pull/30907
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-15 16:22:26 +01:00
Ruben Bridgewater
7327f390f6
repl: remove dead code
The .scope command was used only in the old debugger. Since that's
not part of core anymore it's does not have any use. I tried to
replicate the expected behavior but it even results in just exiting
the repl immediately when using the completion similar to the removed
test case.

PR-URL: https://github.com/nodejs/node/pull/30907
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-15 16:22:24 +01:00
Robert Nagy
67ed526ab0
stream: error state cleanup
Clean up end simplify errored state.

- errorEmitted should be set in the same tick as 'error' is emitted.
- errored should be set as soon as an error occurs.
- errored should exist on Readable as well.
- refactor destroy logic and make it easier to follow.

PR-URL: https://github.com/nodejs/node/pull/30851
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-12-15 15:18:21 +01:00
Ruben Bridgewater
ab59989861
util: add Set and map size to inspect output
This adds the size of a set and map to the output. This aligns the
output with the one from Chromium.

PR-URL: https://github.com/nodejs/node/pull/30225
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-15 14:58:58 +01:00
Ruben Bridgewater
eeae5986fd
util: refactor inspect code for constistency
This removes the special handling to inspect iterable objects with
a null prototype. It is now handled together with the regular
prototype.

PR-URL: https://github.com/nodejs/node/pull/30225
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-15 14:58:57 +01:00
Robert Nagy
e902fadc5e stream: do not throw multiple callback errors in writable
Align ERR_MULTIPLE_CALLBACK in Writable with the rest
of error handling as well as how the error is implemented
in Transform.

PR-URL: https://github.com/nodejs/node/pull/30614
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-14 15:46:24 -08:00
Matteo Collina
f8018f289e stream: do not chunk strings and Buffer in Readable.from
PR-URL: https://github.com/nodejs/node/pull/30912
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-14 16:30:26 -05:00
Robert Nagy
e13a37e49d stream: ensure finish is emitted in next tick
When using end() it was possible for 'finish' to
be emitted synchronously.

PR-URL: https://github.com/nodejs/node/pull/30733
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-14 16:14:41 -05:00
rene.herrmann
952b90ca8d
lib: change var to let/const
PR-URL: https://github.com/nodejs/node/pull/30910
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Jiawen Geng <technicalcute@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-12-14 14:31:41 -05:00
Matteo Collina
648088289d stream: make all streams error in a pipeline
This changes makes all stream in a pipeline emit 'error' in
case of an abnormal termination of the pipeline. If the last stream
is currently being async iterated, this change will make the iteration
reject accordingly.

See: https://github.com/nodejs/node/pull/30861
Fixes: https://github.com/nodejs/node/issues/28194

PR-URL: https://github.com/nodejs/node/pull/30869
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-14 16:16:34 +01:00
Anatoli Papirovski
2e738fb6b5 cluster: remove unnecessary bind
PR-URL: https://github.com/nodejs/node/pull/28131
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-12-14 09:01:52 -05:00
Anatoli Papirovski
af6c88c571 http2: remove unnecessary bind from setImmediate
PR-URL: https://github.com/nodejs/node/pull/28131
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-12-14 09:01:49 -05:00
Anatoli Papirovski
d00d81edd7 fs: remove unnecessary bind
Don't use Function.prototype.bind where it isn't
necessary. Rely on event emitter context instead
and on arrow function as class property.

PR-URL: https://github.com/nodejs/node/pull/28131
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-12-14 09:01:46 -05:00
Anatoli Papirovski
4547574386 perf_hooks: remove unnecessary bind
Pass through parameters using setImmediate rather
than using Function.prototype.bind to bind the
provided context.

PR-URL: https://github.com/nodejs/node/pull/28131
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-12-14 09:01:44 -05:00
Anatoli Papirovski
fea1f1cb9a http: remove unnecessary bind
process.nextTick accepts additional parameters which
are passed through to the callback. Use that instead
of binding the function to a context.

PR-URL: https://github.com/nodejs/node/pull/28131
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-12-14 09:01:42 -05:00
Tim Costa
e17403ede3 http,https: increase server headers timeout
Fixes: https://github.com/nodejs/node/issues/24980
Refs: https://github.com/nodejs/node/commit/eb43bc04b1

PR-URL: https://github.com/nodejs/node/pull/30071
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-14 08:59:19 -05:00
Donggeon Lim
9c460e10d1 lib: use strict equality comparison
Change '==' to '===' in v8_prof_polyfill.js, punycode.js.

PR-URL: https://github.com/nodejs/node/pull/30898
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-14 08:57:36 -05:00
Robert Nagy
d64c1dc24a console: unregister temporary error listener
PR-URL: https://github.com/nodejs/node/pull/30852
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-14 03:03:20 -05:00
Joyee Cheung
e4e5a835b8 lib: refactor NativeModule
Refactor the internal NativeModule class to a JS class and add
more documentation about its properties.

PR-URL: https://github.com/nodejs/node/pull/30856
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-13 20:53:29 -05:00
Michaël Zasso
8e58c7557b repl: fix autocomplete when useGlobal is false
This fixes two issues in the REPL when it is started with a new context
(useGlobal option set to `false`):
- The `primordials` object does not contain all builtins, so the
  filtering based on property names from `primordials` was wrong.
- The autocompleter did not take builtin names into account because
  they are not properties of the context object.

A list of all global builtin names is created lazily when needed. It is
used for filtering for the copy and for adding those names to the
autocompleter list.

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

PR-URL: https://github.com/nodejs/node/pull/30883
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
2019-12-13 20:51:48 -05:00
Sebastien Ahkrin
e490b2ca90 lib: replace Symbol.toPrimitive to SymbolToPrimitive primordials
PR-URL: https://github.com/nodejs/node/pull/30905
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-13 20:05:49 -05:00
Sebastien Ahkrin
ac1cc5c254 lib: update Symbol.toStringTag by SymbolToStringTag primordial
PR-URL: https://github.com/nodejs/node/pull/30908
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-13 15:15:21 -05:00
Ruben Bridgewater
fb8b483c34
util: inspect (user defined) prototype properties
This is only active if the `showHidden` option is truthy.

The implementation is a trade-off between accuracy and performance.
This will miss properties such as properties added to built-in data
types.

The goal is mainly to visualize prototype getters and setters such as:

class Foo {
  ownProperty = true
  get bar() {
    return 'Hello world!'
  }
}

const a = new Foo()

The `bar` property is a non-enumerable property on the prototype while
`ownProperty` will be set directly on the created instance.

The output is similar to the one of Chromium when inspecting objects
closer. The output from Firefox is difficult to compare, since it's
always a structured interactive output and was therefore not taken
into account.

PR-URL: https://github.com/nodejs/node/pull/30768
Fixes: https://github.com/nodejs/node/issues/30183
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-12-13 20:00:19 +01:00
Ruben Bridgewater
28ee032fca
util: fix built-in detection
This makes sure that the regular expression matches all built-in
objects properly. So far a couple where missed.

PR-URL: https://github.com/nodejs/node/pull/30768
Fixes: https://github.com/nodejs/node/issues/30183
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-12-13 19:57:31 +01:00
Michaël Zasso
923d8bc733
lib: enforce use of BigInt from primordials
PR-URL: https://github.com/nodejs/node/pull/30882
Refs: https://github.com/nodejs/node/issues/30697
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2019-12-13 15:54:53 +01:00
Guy Bedford
357a99293e module: conditional exports import condition
PR-URL: https://github.com/nodejs/node/pull/30799
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2019-12-12 17:35:08 -05:00
Denys Otrishko
2dff8ddafb
http2: forward debug message in debugStreamObj
PR-URL: https://github.com/nodejs/node/pull/30840
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2019-12-12 10:04:48 -05:00
Kamat, Trivikram
9c32b24b65 url: declare iterator inside loop
Refs: https://github.com/nodejs/node/pull/30281#discussion_r343380565

PR-URL: https://github.com/nodejs/node/pull/30509
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-12-11 16:38:06 -06:00
Sebastien Ahkrin
c101251a95
lib: replace Symbol.iterator by SymbolIterator
PR-URL: https://github.com/nodejs/node/pull/30859
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-12-11 11:02:35 +01:00
Sebastien Ahkrin
11465d3b0e
lib: replace every Symbol.for by SymbolFor primordials
PR-URL: https://github.com/nodejs/node/pull/30857
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-12-11 11:02:13 +01:00
Robert Nagy
855ca736de net: remove duplicate _undestroy
initSocketHandle will call _undestroy.

PR-URL: https://github.com/nodejs/node/pull/30833
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-12-11 05:58:42 +01:00
Anna Henningsen
8a5c7f6abd
fs: synchronize close with other I/O for streams
Part of the flakiness in the
parallel/test-readline-async-iterators-destroy test comes from
fs streams starting `_read()` and `_destroy()` without waiting
for the other to finish, which can lead to the `fs.read()` call
resulting in `EBADF` if timing is bad.

Fix this by synchronizing write and read operations with `close()`.

Refs: https://github.com/nodejs/node/issues/30660

PR-URL: https://github.com/nodejs/node/pull/30837
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-10 10:04:00 -05:00
cjihrig
350654acd5
fs: retry unlink operations in rimraf
This commit adds synchronous retry logic to
the unlinkSync() calls in rimraf.

PR-URL: https://github.com/nodejs/node/pull/30569
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-12-10 09:22:15 -05:00
cjihrig
152014a893
fs: only operate on buffers in rimraf
PR-URL: https://github.com/nodejs/node/pull/30569
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-12-10 09:22:02 -05:00
ZYSzys
7629fb25f2 module: fix require in node repl
Fixes: https://github.com/nodejs/node/issues/30808

PR-URL: https://github.com/nodejs/node/pull/30835
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-10 09:34:06 +08:00
jens-cappelle
f393d66881
lib: replace var with let/const
PR-URL: https://github.com/nodejs/node/pull/30384
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-12-10 01:43:53 +01:00
Ruben Bridgewater
6bdf8d1060
repl: support previews by eager evaluating input
This adds input previews by using the inspectors eager evaluation
functionality.
It is implemented as additional line that is not counted towards
the actual input. In case no colors are supported, it will be visible
as comment. Otherwise it's grey.
It will be triggered on any line change. It is heavily tested against
edge cases and adheres to "dumb" terminals (previews are deactived
in that case).

PR-URL: https://github.com/nodejs/node/pull/30811
Fixes: https://github.com/nodejs/node/issues/20977
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-12-10 00:23:23 +01:00
Sam Roberts
02a0c74861 http: llhttp opt-in insecure HTTP header parsing
Allow insecure HTTP header parsing. Make clear it is insecure.

See:
- https://github.com/nodejs/node/pull/30553
- https://github.com/nodejs/node/issues/27711#issuecomment-556265881
- https://github.com/nodejs/node/issues/30515

PR-URL: https://github.com/nodejs/node/pull/30567
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-09 09:56:16 -08:00
cjihrig
d7b8ae72d9 fs: reduce unnecessary sync rimraf retries
rimraf should only retry if certain errors are encountered.
Additionally, there is no point sleeping if an error occurs
on the last try.

PR-URL: https://github.com/nodejs/node/pull/30785
Fixes: https://github.com/nodejs/node/issues/30580
Refs: https://github.com/nodejs/node/pull/30569
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-12-09 07:15:29 +01:00
cjihrig
26991d0831 fs: add synchronous retries to rimraf
This commit gives the synchronous version of rimraf the same
linear retry logic as the asynchronous version. Prior to this
commit, sync rimraf kept retrying the operation as soon as
possible until maxRetries was reached.

PR-URL: https://github.com/nodejs/node/pull/30785
Fixes: https://github.com/nodejs/node/issues/30580
Refs: https://github.com/nodejs/node/pull/30569
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-12-09 07:15:29 +01:00
Sebastien Ahkrin
eac3f0adc4
lib: replace Symbol global by the primordials Symbol
PR-URL: https://github.com/nodejs/node/pull/30737
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-12-08 13:38:58 +01:00
Ruben Bridgewater
254398a0be readline: eagerly load string_decoder
There was no point in lazy loading the string_decoder, since it
would be used in all cases anyway.

PR-URL: https://github.com/nodejs/node/pull/30807
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-07 10:16:10 -08:00
qualitymanifest
7ab21b2f57 lib: add parent to ERR_UNKNOWN_FILE_EXTENSION
- default_resolve updated to pass parentURL into error
- ERR_UNKNOWN_FILE_EXTENSION updated to include parentURL
- test added to check for import message in error

PR-URL: https://github.com/nodejs/node/pull/30728
Fixes: https://github.com/nodejs/node/issues/30721
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-12-06 23:59:39 -05:00
Juan José Arboleda
6669cd138e lib: add warning on dynamic import es modules
PR-URL: https://github.com/nodejs/node/pull/30720
Reviewed-By: Guy Bedford <guybedford@gmail.com>
2019-12-06 23:07:56 -05:00
cjihrig
f446929923
util: add internal sleep() function
PR-URL: https://github.com/nodejs/node/pull/30787
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-12-06 22:02:47 -05:00
Corey Farrell
4ec02d5afd
module: fix dynamic import from eval
This allows dynamic import to work from CLI `--eval` with or without
`--input-type=module`.

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

PR-URL: https://github.com/nodejs/node/pull/30624
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com>
Reviewed-By: Ben Coe <bencoe@gmail.com>
2019-12-06 17:55:02 -08:00
Ruben Bridgewater
5360dd151d
assert: handle (deep) equal(NaN, NaN) as being identical
This aligns the `equal` and `deepEqual()` implementations with the
strict versions by accepting `NaN` as being identical in case both
sides are NaN.

Refs: https://github.com/nodejs/node/issues/30350#issuecomment-552191641

PR-URL: https://github.com/nodejs/node/pull/30766
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-07 00:43:51 +01:00
Ruben Bridgewater
b4d48c0516
assert,util: stricter type comparison using deep equal comparisons
This veryfies that both input arguments are always of the identical
type. It was possible to miss a few cases before. This change applies
to all deep equal assert functions (e.g., `assert.deepStrictEqual()`)
and to `util.isDeepStrictEqual()`.

PR-URL: https://github.com/nodejs/node/pull/30764
Refs: https://github.com/nodejs/node/pull/30743
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-07 00:40:53 +01:00
Ruben Bridgewater
e11b909097
util: never trigger any proxy traps using format()
PR-URL: https://github.com/nodejs/node/pull/30767
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-07 00:38:29 +01:00
Ruben Bridgewater
c430aebe86
util: improve performance inspecting proxies
This makes sure we do not retrieve the handler in case it's not
required. This improves the performance a tiny bit for these cases.

PR-URL: https://github.com/nodejs/node/pull/30767
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-07 00:38:28 +01:00