V7.8.0 proposal by MylesBorins · Pull Request #12104 · nodejs/node

@targos

This is a backport of https://codereview.chromium.org/2672313003/. The
patch did not land in V8 because it was superseded by another one but it
is much easier to backport to V8 5.5, was reviewed and passed tests.

Original commit message:

    [async await] Fix async function desugaring

    Previously we rewrote the return statement in an async function from
    `return expr;` to `return %ResolvePromise(.promise, expr),
    .promise`. This can lead to incorrect behavior in the presence of try-finally.

    This patch stores the `expr` of the return statement in a temporary
    variable, resolves and returns the promise at the end of the finally
    block.

    BUG=v8:5896

PR-URL: #12004
Fixes: #11960
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>

@Trott @MylesBorins

lib/buffer.js uses a function declaration for `Buffer`. So it never
uses an instance of `Buffer` in the global scope. Therefore the
disabling of the `require-buffer` custom rule is not needed. Remove the
comment.

PR-URL: #11906
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>

@DannyNemer @MylesBorins

Adds `options.deDupeHistory` for `readline.createInterface(options)`. If
`options.deDupeHistory` is `true`, when a new input line being added to
the history list duplicates an older one, removes the older line from
the list. Defaults to `false`.

Many users would appreciate this option, as it is a common setting in
shells. This option certainly should not be default behavior, as it
would be problematic in applications such as the `repl`, which inherits
from the readline `Interface`.

Extends documentation to reflect this API addition.

Adds tests for when `options.deDupeHistory` is truthy, and when
`options.deDupeHistory` is falsey.

PR-URL: #2982
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>

@watilde @MylesBorins

Since file URLs can not have `username/password/port`,
the specification was updated to restrict setting protocol to "file".

Refs: whatwg/url#269
Fixes: #11785
PR-URL: #11887
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>

@watilde @MylesBorins

Synchronize url-setter-test to upstream.

Refs: web-platform-tests/wpt#5112
PR-URL: #11887
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>

@jyotman @MylesBorins

PR-URL: #11914
Fixes: #11913
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

@bzoz @MylesBorins

Check that stdin, stdout and stderr are valid file descriptors on
Windows. If not, reopen them with 'nul' file.

Refs: #875
Fixes: #11656
PR-URL: #11863
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>

@silverwind @MylesBorins

GitHub now renders Markdown in CommonMark where spaces in a link
destination are invalid and need to be escaped.

PR-URL: #11944
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>

@danbev @MylesBorins

Currently test-tls-socket-close will fail if node
was built using --without-ssl. This commit adds a check to
verify is crypto support exists and if not skip this test.

PR-URL: #11911
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>

@lucaslago @MylesBorins

This removes common.v8ForceOptimization calls from url and vm benchmark
files.

PR-URL: #11908
Fixes: #11895
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>

@vsemozhetbyt @MylesBorins

Make it call-site-cwd-independent.

PR-URL: #11904
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>

@TimothyGu @MylesBorins

It only returns 0, nor is it likely to have any error conditions in the
future.

PR-URL: #11922
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

@Trott @MylesBorins

Replace timer/timeout race with event-based ordering, eliminating test
flakiness.

PR-URL: #11921
Fixes: #11912
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

@Trott @MylesBorins

While `child_process.execFile()` gets called in places in the test
suite, there are no explicit test for it and there are parts of the
implementation that are not covered by tests. This adds a minimal test
that increases (but does not complete) coverage for the implementation.

PR-URL: #11929
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>

@TimothyGu @MylesBorins

Also add test cases for partial writes and invalid indices.

PR-URL: #11927
Fixes: #8724
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>

@vsemozhetbyt @MylesBorins

Add a space for minimal readability.

PR-URL: #11925
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

@diastremskii @MylesBorins

Let make-standalone-toolchain.sh create directory.

PR-URL: #11916
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>

@bmeck @MylesBorins

PR-URL: #11897
Fixes: #7151
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>

@davidtaikocha @MylesBorins

PR-URL: #11891
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>

@Trott @MylesBorins

Remove superfluous sample code. Since `assert()` is documented as an
alias of `assert.ok()` and nothing more, the sample code for
`assert.ok()` is sufficient.

PR-URL: #11933
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

@jasnell @MylesBorins

Adds a URL native class for use within the node.js c/c++
code. This is primarily intended to be used by the eventual
ES6 modules implementation but can be used generally wherever
URL parsing within the c/c++ may be necessary.

```c
URL url1("http://example.org");
URL url2("foo", "http://example.org/bar");
URL url3("baz", &url2);
```

While we're at it, reduce reliance on macros to simplify impl.

PR-URL: #11801
Reviewed-By: Anna Henningsen <anna@addaleax.net>

@DannyNemer @MylesBorins

Renames `options.deDupeHistory` → `options.removeHistoryDuplicates` for
`readline.createInterface(options)`.

The option name `removeHistoryDuplicates` is preferable to the
semantically identical name `deDupeHistory` because "dedupe" (short for
"deduplication") is obscure and neologistic while
`removeHistoryDuplicates` is clear, though verbose.

Updates tests and documentation for this option accordingly.

PR-URL: #11950
Ref: #2982
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

@vsemozhetbyt @MylesBorins

`child.stderr`, `child.stdin`, and `child.stdout`
are `null`, not `undefined`, if the relevant `stdio` properties
are set to anything other than 'pipe'.

PR-URL: #11949
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

@bnoordhuis @MylesBorins

Replace a few calls to FIXED_ONE_BYTE_STRING() with their persistent
counterparts from `node::Environment`.  None of the calls are in hot
code paths but why create a new string when one already exists?

PR-URL: #11945
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>

@seishun @MylesBorins

This allows running a benchmark with two or more values for the same
config rather than just one or all of them, for example:

```
node benchmark/buffers/buffer-creation.js type=buffer() type=fast-alloc type=fast-alloc-fill
```

PR-URL: #11819
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>

@shigeki @MylesBorins

The timer handle is reused when it is unrefed in order to avoid new
callback in beforeExit(#3407). If it is unrefed within a setInterval
callback, the reused timer handle is closed so that setInterval no
longer keep working. This fix does not close the handle in case of
setInterval.

PR-URL: #11646
Reviewed-By: Julien Gilli <jgilli@nodejs.org>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

@zkat @MylesBorins

PR-URL: #11389
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>

@Trott @MylesBorins

Per email conversation with Shigeki Ohtsu, updating email address in
docs. The current listed email address does not work anymore.

PR-URL: #11996
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Shigeki Ohtsu <ohtsu@ohtsu.org>

@vsemozhetbyt @MylesBorins

PR-URL: #11953
Fixes: #11469
Reviewed-By: João Reis <reis@janeasystems.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>

@joyeecheung @MylesBorins

PR-URL: #11934
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>