29463 Commits
Author SHA1 Message Date
Shelley Vohr 3443e3ad4c 2020-04-08 Version 12.16.2 (LTS)
Notable changes:

doc:
  * add ronag to collaborators (Robert Nagy) [#31498](https://github.com/nodejs/node/pull/31498)
  * add GeoffreyBooth to collaborators (Geoffrey Booth) [#31306](https://github.com/nodejs/node/pull/31306)
deps:
  * upgrade npm to 6.13.6 (Ruy Adorno) [#31304](https://github.com/nodejs/node/pull/31304)
  * update openssl to 1.1.1e (Hassaan Pasha) [#32328](https://github.com/nodejs/node/pull/32328)
v12.16.2
2020-04-07 20:35:33 -07:00
Richard Lau e685f12ee6 test: restore --jitless test on AIX
PR-URL: https://github.com/nodejs/node/pull/32619
Refs: https://github.com/v8/v8/commit/07ee86a5a28b7f9526748ca8f765c1b704f93c0c
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-04-03 16:00:11 -04:00
Milad Farazmand a1be32752c deps: V8: backport 07ee86a5a28b
Original commit message:

    PPC: allow for calling CFunctions without function descriptors on AIX.

    The calling conventions on AIX uses function descriptors,
    which means that pointers to functions do not point to code,
    but instead point to metadata about them. When calling JITed code,
    we must assure to use function descriptors instead of raw pointers when
    needed. Before this CL 213504b, all CallCFunction on AIX were guaranteed to have
    function descriptors. Starting form the CL mentioned above, CallCFunction can also
    Jump to a Trampoline which does not have a function descriptor, hence a new
    "CallCFunctionWithoutFunctionDescriptor" method is proposed to deal with this issue.

    BUG= v8:9766

    Change-Id: I9343c31c812f5d4dda8503a5adf024b24dbde072
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1825961
    Commit-Queue: Milad Farazmand <miladfar@ca.ibm.com>
    Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
    Reviewed-by: Jakob Gruber <jgruber@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#64357}

Refs: https://github.com/v8/v8/commit/07ee86a5a28b7f9526748ca8f765c1b704f93c0c

PR-URL: https://github.com/nodejs/node/pull/32619
Refs: https://github.com/v8/v8/commit/07ee86a5a28b7f9526748ca8f765c1b704f93c0c
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2020-04-03 15:59:50 -04:00
Myles Borins e88960d1f4 doc: esm spec bug
PR-URL: https://github.com/nodejs/node/pull/32610
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
2020-04-03 15:57:04 -04:00
Guy BedfordandGeoffrey Booth 155a6c397d doc: update conditional exports recommendations
Backport-PR-URL: https://github.com/nodejs/node/pull/32610
Co-Authored-By: Geoffrey Booth <GeoffreyBooth@users.noreply.github.com>
PR-URL: https://github.com/nodejs/node/pull/32098
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
2020-04-03 15:57:02 -04:00
Nick Schonning 45d05e1cf6 build: add mjs extension to lint-js
This matches what the lint-js make target passes through the CLI.

Backport-PR-URL: https://github.com/nodejs/node/pull/32610
PR-URL: https://github.com/nodejs/node/pull/32145
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
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: Trivikram Kamat <trivikr.dev@gmail.com>
2020-04-03 15:56:59 -04:00
Rich Trott 7e56e3dee3 doc: remove unnecessary "obvious(ly)" modifiers in esm.md
Remove "obvious" and "obviously" in two places in esm.md. It may be
obvious to some, but likely not everyone or else it probably wouldn't be
worth mentioning/documenting.

Backport-PR-URL: https://github.com/nodejs/node/pull/32610
PR-URL: https://github.com/nodejs/node/pull/32457
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2020-04-03 15:56:57 -04:00
Richard Lau 61f44c94ae doc: fix lint warning in doc/api/esm.md
Signed-off-by: Richard Lau <riclau@uk.ibm.com>

Backport-PR-URL: https://github.com/nodejs/node/pull/32610
PR-URL: https://github.com/nodejs/node/pull/32462
Refs: https://github.com/nodejs/node/pull/31479
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-04-03 15:56:54 -04:00
Rich Trott d8e17bf12a doc: improve wording in esm.md
Simplify complex sentence. Remove use of "straightforward".

Backport-PR-URL: https://github.com/nodejs/node/pull/32610
PR-URL: https://github.com/nodejs/node/pull/32427
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-04-03 15:56:51 -04:00
Eric Dobbertin 8b961347fe doc: import clarifications with links to MDN
Backport-PR-URL: https://github.com/nodejs/node/pull/32610
PR-URL: https://github.com/nodejs/node/pull/31479
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2020-04-03 15:56:49 -04:00
Jan Krems 62b5bd4ca0 module: add hook for global preload code
Backport-PR-URL: https://github.com/nodejs/node/pull/32610
PR-URL: https://github.com/nodejs/node/pull/32068
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
2020-04-03 15:56:45 -04:00
himself65 0e513b2ae7 esm: remove unused parameter on module.instantiate
Backport-PR-URL: https://github.com/nodejs/node/pull/32610
PR-URL: https://github.com/nodejs/node/pull/32147
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2020-04-03 15:56:43 -04:00
Guy Bedford c537afb18c module: package "exports" error refinements
Backport-PR-URL: https://github.com/nodejs/node/pull/32610
PR-URL: https://github.com/nodejs/node/pull/31625
Reviewed-By: Jan Krems <jan.krems@gmail.com>
2020-04-03 15:56:41 -04:00
Guy Bedford 05091d48e3 esm: import.meta.resolve with nodejs: builtins
Backport-PR-URL: https://github.com/nodejs/node/pull/32610
PR-URL: https://github.com/nodejs/node/pull/31032
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2020-04-03 15:56:32 -04:00
Rich Trott c0e6e60cb1 tools: update minimist@1.2.5
Update minimist used by lint-md.js to 1.2.5.

Refs: https://app.snyk.io/vuln/SNYK-JS-MINIMIST-559764
Signed-off-by: Rich Trott <rtrott@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/32274
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-04-02 00:58:42 -04:00
Christian Clauss fae680f740 build: drop Travis in favor of Actions
GitHub Actions is running all tests already present on Travis, as well
as building on more platforms (OS X and Windows). With Travis we're also
getting timeouts more frequently than with Actions, which gives the
false impression tests are failing (making it harder to triage PRs ready
to merge).

To make our config simpler, CI.yml and pythonpackage.yml got merged. The
coverage is also increased by running tests on OS X.

Signed-off-by: Matheus Marchini <mmarchini@netflix.com>

Backport-PR-URL: https://github.com/nodejs/node/pull/32608
PR-URL: https://github.com/nodejs/node/pull/32450
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2020-04-02 00:49:46 -04:00
Richard Lau a50648975d build: annotate markdown lint failures in pull requests
Add a problem matcher for output from remark-lint to our lint-md GitHub
Actions CI workflow so that any markdown linter failures are annotated
in the pull request in the web UI.

Signed-off-by: Richard Lau <riclau@uk.ibm.com>

Backport-PR-URL: https://github.com/nodejs/node/pull/32608
PR-URL: https://github.com/nodejs/node/pull/32391
Refs: https://github.com/actions/toolkit/blob/master/docs/problem-matchers.md
Refs: https://github.com/actions/toolkit/blob/master/docs/commands.md#problem-matchers
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
2020-04-02 00:49:46 -04:00
Richard Lau c42cb79bb7 build: build docs in GitHub Actions CI workflow
Backport-PR-URL: https://github.com/nodejs/node/pull/32608
PR-URL: https://github.com/nodejs/node/pull/31504
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-04-02 00:49:45 -04:00
Richard Lau 46f83df2fd build: do not use setup-node in build workflows
The setup-node GitHub Action installs problem matchers that happen
to match the warning message format of Visual Studio's C/C++ compiler.
This is resulting in all of our pull requests being annotated with
`Unchanged files with check annotations` which are confusing to new
contributors as they are not due to the changes in the pull request.

The action is used to run `npx envinfo` to dump some information into
the logs before the actual build. All GitHub hosted runners already
have a version of Node.js installed (12.x at the time of this commit)
which we can use to run `envinfo`. Remove the action to avoid using
the problematic problem matcher.

Backport-PR-URL: https://github.com/nodejs/node/pull/32608
PR-URL: https://github.com/nodejs/node/pull/31349
Fixes: https://github.com/nodejs/node/issues/31347
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-04-02 00:49:45 -04:00
扩散性百万甜面包 ad12c82e37 build: fix macos runner type in GitHub Action
Backport-PR-URL: https://github.com/nodejs/node/pull/32608
PR-URL: https://github.com/nodejs/node/pull/31327
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-04-02 00:49:45 -04:00
Richard Lau df701f3b12 build: fix step name in GitHub Actions workflow
The CI workflow doesn't use the matrix strategy so there is no
`${{ matrix.node-version }}` variable to use in the `Use Node.js`
step names.

Backport-PR-URL: https://github.com/nodejs/node/pull/32608
PR-URL: https://github.com/nodejs/node/pull/31323
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-02 00:49:45 -04:00
Richard Lau d190ee06b4 build: add GitHub actions to run linters
Add jobs to our GitHub Actions workflow to run our
various lint Makefile targets. The `setup-node` action
used to run the JavaScript linter contains problem
matchers for eslint that will annotate the files in a pull
request if there are failures.

Backport-PR-URL: https://github.com/nodejs/node/pull/32608
PR-URL: https://github.com/nodejs/node/pull/31323
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-02 00:49:45 -04:00
gengjiawen 782f5dbddd src: add build Github Action
Backport-PR-URL: https://github.com/nodejs/node/pull/32608
PR-URL: https://github.com/nodejs/node/pull/31153
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-02 00:49:45 -04:00
ExE Boss 32c0449141 util: use a global symbol for util.promisify.custom
Define `util.promisify.custom`
as `Symbol.for("nodejs.util.inspect.custom")`, rather than
as `Symbol("util.inspect.custom")`.

This allows custom `promisify` wrappers to easily/safely be defined
in non‑Node.js environments.

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

Backport-PR-URL: https://github.com/nodejs/node/pull/32349
PR-URL: https://github.com/nodejs/node/pull/31672
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2020-04-02 00:47:42 -04:00
Anna Henningsen eee587b847 test: fix test-http2-reset-flood flakiness
Refs: https://github.com/nodejs/node/issues/29802#issuecomment-607522598

PR-URL: https://github.com/nodejs/node/pull/32607
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-04-02 00:47:08 -04:00
Gerhard Stoebich a83fc49717 deps: V8: cherry-pick cb1c2b0fbfe7
Original commit message:

    Remove noscript_shared_function_infos

    SharedFunctionInfos that do not belong to a script were tracked in
    noscript_shared_function_infos. However this was only used in object-stats.
    Remove this since it was actually leaking memory in some use cases.

    Bug: v8:9674
    Change-Id: I9482f7e5dedf975666a70684b3d2ea04c9a23518
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1798423
    Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
    Reviewed-by: Michael Stanton <mvstanton@chromium.org>
    Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#63685}

PR-URL: https://github.com/nodejs/node/pull/31939
Refs: https://github.com/v8/v8/commit/cb1c2b0fbfe730ed46d2b7a1ad3f58a21facc477
Refs: https://github.com/nodejs/node/issues/31914
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
2020-04-01 23:49:42 -04:00
Matheus Marchini 784df12494 deps: revert whitespace changes on V8
While landing some of the V8 upgrades on the v12 branch, something went
wrong and git made unecessary (and incorrect) whitespace changes to test
fixtures, which broke V8 tests. This was likely caused by the use of
`git node land` or a simiar tool. Revert those changes to fix our tests.
Since this only reverts unwanted changes on deps/v8, and it only affects
tests, don't bump v8_embedder_string.

PR-URL: https://github.com/nodejs/node/pull/32605
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
2020-04-01 23:33:40 -04:00
Myles Borins f58594b8ec doc: update releaser list in README.md
Moved emeritus members keys and fixed alphabetization issues

PR-URL: https://github.com/nodejs/node/pull/32577
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-04-01 19:11:57 -04:00
Robert Nagy 12253f8c74 stream: sync stream unpipe resume
pipe() ondata should not control flow state if cleaned up.

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

Backport-PR-URL: https://github.com/nodejs/node/pull/32264
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>
Backport-PR-URL: https://github.com/nodejs/node/pull/32264
2020-04-01 19:09:37 -04:00
Rod Vagg 885c88ee5b doc: official macOS builds now on 10.15 + Xcode 11
Backport-PR-URL: https://github.com/nodejs/node/pull/32527
PR-URL: https://github.com/nodejs/node/pull/31459
Refs: https://github.com/nodejs/node/issues/29216
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Ash Cripps <ashley.cripps@ibm.com>
Signed-off-by: Rod Vagg <rod@vagg.org>
2020-04-01 18:00:04 -04:00
Rod Vagg 7d3910d078 build: macOS package notarization
Includes hardened-runtime patch from gdams from
https://github.com/nodejs/node/issues/29216#issuecomment-546932966

Backport-PR-URL: https://github.com/nodejs/node/pull/32527
PR-URL: https://github.com/nodejs/node/pull/31459
Refs: https://github.com/nodejs/node/issues/29216
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Ash Cripps <ashley.cripps@ibm.com>
Signed-off-by: Rod Vagg <rod@vagg.org>
2020-04-01 18:00:01 -04:00
Ruy Adorno 6db190bb1c deps: upgrade npm to 6.14.4
Backport-PR-URL: https://github.com/nodejs/node/pull/32527
PR-URL: https://github.com/nodejs/node/pull/32495
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
2020-04-01 17:59:58 -04:00
Rod Vagg 652ffa5470 deps: update term-size with signed version
Backport-PR-URL: https://github.com/nodejs/node/pull/32527
PR-URL: https://github.com/nodejs/node/pull/31459
Refs: https://github.com/nodejs/node/issues/29216
Refs: https://github.com/sindresorhus/macos-term-size/pull/3
Reviewed-By: Christian Clauss <cclauss@me.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Ash Cripps <ashley.cripps@ibm.com>
Signed-off-by: Rod Vagg <rod@vagg.org>
2020-04-01 17:59:56 -04:00
Ben Noordhuis f55d071bfd deps: remove *.pyc files from deps/npm
These seem to have accidentally slipped into the npm source tarball and
cause problems when contributors update their git checkout of node.

Backport-PR-URL: https://github.com/nodejs/node/pull/32527
PR-URL: https://github.com/nodejs/node/pull/32387
Refs: https://github.com/nodejs/node/pull/32368
Refs: https://github.com/npm/cli/issues/1037
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2020-04-01 17:59:53 -04:00
Myles Borins c419cd21e3 deps: update npm to 6.14.3
Backport-PR-URL: https://github.com/nodejs/node/pull/32527
PR-URL: https://github.com/nodejs/node/pull/32368
Refs: https://github.com/nodejs/node/issues/32296
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2020-04-01 17:59:50 -04:00
isaacs 17217a5275 deps: upgrade npm to 6.14.1
Backport-PR-URL: https://github.com/nodejs/node/pull/32527
PR-URL: https://github.com/nodejs/node/pull/31977
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2020-04-01 17:59:42 -04:00
Anna Henningsen fbd5be6734 src: delete BaseObjectWeakPtr data when pointee is gone
Fix the condition for deleting the underlying data pointed to by
a `BaseObjectWeakPtr`, which erroneously skipped that deletion
when `ptr->get()` was `nullptr`. This fixes a memory leak reported
by some of the tests.

Refs: https://github.com/nodejs/node/pull/30374#issuecomment-601848973

Backport-PR-URL: https://github.com/nodejs/node/pull/32301
PR-URL: https://github.com/nodejs/node/pull/32393
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-04-01 17:37:26 -04:00
Anna Henningsen 56a45095b7 src: harden running native SetImmediate()s slightly
Prevent mistakes like the one fixed by the previous commit
by destroying the callback immediately after it has been called.

Backport-PR-URL: https://github.com/nodejs/node/pull/32301
PR-URL: https://github.com/nodejs/node/pull/31468
Refs: https://github.com/nodejs/node/pull/31386
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2020-04-01 17:37:23 -04:00
Anna Henningsen c5de212039 worker: move JoinThread() back into exit callback
de2c68c7dd moved this call to
the destructor, under the assumption that that would essentially
be equivalent to running it as part of the callback since the
worker would be destroyed along with the callback.

However, the actual code in
`Environment::RunAndClearNativeImmediates()` comes with the subtlety
that testing whether a JS exception has been thrown
happens between the invocation of the callback and its destruction,
leaving a possible exception from `JoinThread()` potentially
unhandled (and unintentionally silenced through the `TryCatch`).

This affected exceptions thrown from the `'exit'` event of the
Worker, and made the `parallel/test-worker-message-type-unknown`
test flaky, as the invalid message was sometimes only received
during the Worker thread’s exit handler.

Fix this by moving the `JoinThread()` call back to where it was
before.

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

Backport-PR-URL: https://github.com/nodejs/node/pull/32301
PR-URL: https://github.com/nodejs/node/pull/31468
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2020-04-01 17:37:19 -04:00
Anna Henningsen cb16aabd15 src: simplify native immediate queue running
Make `SetImmediate()` behave more like `process.nextTick()`
(which matches how we use it) by also running tasks that have been
added during previous `SetImmediate()` calls.

Backport-PR-URL: https://github.com/nodejs/node/pull/32301
PR-URL: https://github.com/nodejs/node/pull/31502
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2020-04-01 17:37:15 -04:00
Anna Henningsen 87cfbb2da1 report: add support for Workers
Include a report for each sub-Worker of the current Node.js instance.

This adds a feature that is necessary for eventually making the report
feature stable, as was discussed during the last collaborator summit.

Refs: https://github.com/openjs-foundation/summit/pull/240

Backport-PR-URL: https://github.com/nodejs/node/pull/32301
PR-URL: https://github.com/nodejs/node/pull/31386
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-04-01 17:37:13 -04:00
Anna Henningsen c2176e15ea src: move MemoryInfo() for worker code to .cc files
This is a) the right thing to do anyway because these functions
can not be inlined by the compiler and b) avoids compilation warnings
in the following commit.

Backport-PR-URL: https://github.com/nodejs/node/pull/32301
PR-URL: https://github.com/nodejs/node/pull/31386
Refs: https://github.com/openjs-foundation/summit/pull/240
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-04-01 17:37:10 -04:00
Anna Henningsen 22bf867149 src: add interrupts to Environments/Workers
Allow doing what V8’s `v8::Isolate::RequestInterrupt()` does for V8.
This also works when there is no JS code currently executing.

Backport-PR-URL: https://github.com/nodejs/node/pull/32301
PR-URL: https://github.com/nodejs/node/pull/31386
Refs: https://github.com/openjs-foundation/summit/pull/240
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-04-01 17:37:07 -04:00
Anna Henningsen 7c2c068aeb src: remove AsyncRequest
Remove `AsyncRequest` from the source code, and replace its
usage with threadsafe `SetImmediate()` calls. This has the
advantage of being able to pass in any function, rather than
one that is defined when the `AsyncRequest` is “installed”.

This necessitates two changes:

- The stopping flag (which was only used in one case and ignored
  in the other) is now a direct member of the `Environment` class.
- Workers no longer have their own libuv handles, requiring
  manual management of their libuv ref count.

As a drive-by fix, the `can_call_into_js` variable was turned
into an atomic variable. While there have been no bug reports,
the flag is set from `Stop(env)` calls, which are supposed to
be possible from any thread.

Backport-PR-URL: https://github.com/nodejs/node/pull/32301
PR-URL: https://github.com/nodejs/node/pull/31386
Refs: https://github.com/openjs-foundation/summit/pull/240
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-04-01 17:37:04 -04:00
Anna Henningsen 748a530046 src: add a threadsafe variant of SetImmediate()
Add a variant of `SetImmediate()` that can be called from any thread.
This allows removing the `AsyncRequest` abstraction and replaces it
with a more generic mechanism.

Backport-PR-URL: https://github.com/nodejs/node/pull/32301
PR-URL: https://github.com/nodejs/node/pull/31386
Refs: https://github.com/openjs-foundation/summit/pull/240
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-04-01 17:37:01 -04:00
Anna Henningsen aafb224147 src: exclude C++ SetImmediate() from count
There is no real reason to manage a count manually, given that
checking whether there are C++ callbacks is a single pointer
comparison.

This makes it easier to add other kinds of native C++ callbacks
that are managed in a similar way.

Backport-PR-URL: https://github.com/nodejs/node/pull/32301
PR-URL: https://github.com/nodejs/node/pull/31386
Refs: https://github.com/openjs-foundation/summit/pull/240
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-04-01 17:36:59 -04:00
Anna Henningsen 5df969826d src: better encapsulate native immediate list
Refactor for clarity and reusability. Make it more obvious that the
list is a FIFO queue.

Backport-PR-URL: https://github.com/nodejs/node/pull/32301
PR-URL: https://github.com/nodejs/node/pull/31386
Refs: https://github.com/openjs-foundation/summit/pull/240
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-04-01 17:36:56 -04:00
Anna Henningsen 2625244111 src: run native immediates during Environment cleanup
This can be necessary, because some parts of the Node.js code base
perform cleanup operations in the Immediate callbacks, e.g. HTTP/2.

This resolves flakiness in an HTTP/2 test that failed when a
`SetImmediate()` callback was not run or destroyed before the
`Environment` destructor started, because that callback held a
strong reference to the `Http2Session` object and the expectation
was that no such objects exist once the `Environment` constructor
starts.

Another, slightly more direct, alternative would have
been to clear the immediate queue rather than to run it. However,
this approach seems to make more sense as code generally assumes
that the `SetImmediate()` callback will always run; For example,
N-API uses an immediate callback to call buffer finalization
callbacks.

Unref’ed immediates are skipped, as the expectation is generally
that they may not run anyway.

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

Backport-PR-URL: https://github.com/nodejs/node/pull/32301
PR-URL: https://github.com/nodejs/node/pull/30666
Refs: https://github.com/nodejs/node/pull/30374
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-04-01 17:36:53 -04:00
Anna Henningsen 5b65348fed src: no SetImmediate from destructor in stream_pipe code
Guard against running `SetImmediate()` from the destructor.
The object will not be alive or usable in the callback,
so it does not make sense to attempt to schedule the
`SetImmediate()`.

Backport-PR-URL: https://github.com/nodejs/node/pull/32301
PR-URL: https://github.com/nodejs/node/pull/30666
Fixes: https://github.com/nodejs/node/issues/30643
Refs: https://github.com/nodejs/node/pull/30374
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-04-01 17:36:50 -04:00
Anna Henningsen 51230f71ff src: add more can_call_into_js() guards
This is in preparation for running native `SetImmediate()`
callbacks during shutdown.

Backport-PR-URL: https://github.com/nodejs/node/pull/32301
PR-URL: https://github.com/nodejs/node/pull/30666
Fixes: https://github.com/nodejs/node/issues/30643
Refs: https://github.com/nodejs/node/pull/30374
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-04-01 17:36:48 -04:00