Commit Graph

33626 Commits

Author SHA1 Message Date
Richard Lau
6434cd66bb doc: mark Node.js 10 as End-of-Life
PR-URL: https://github.com/nodejs/node/pull/38482
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2021-04-30 12:06:14 -04:00
James M Snell
d85929c32a meta: post comment when pr labeled fast-track
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/38446
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Mary Marchini <oss@mmarchini.me>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2021-04-30 06:43:01 -07:00
Guy Bedford
50991df0f7 deps: update to cjs-module-lexer@1.2.1
PR-URL: https://github.com/nodejs/node/pull/38450
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-04-30 14:43:48 +02:00
Shelley Vohr
bdaf51bae7 src: allow custom PageAllocator in NodePlatform
For certain embedder use cases there are more complex memory allocation
requirements that the default V8 page allocator does not handle.
For example, using MAP_JIT when running under a hardened runtime
environment on macOS. This allows embedders like Electron to provide
their own allocator that does handle these cases.

PR-URL: https://github.com/nodejs/node/pull/38362
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-04-30 09:13:21 +02:00
Leko
746cc88b92 test: update url Web Platform Tests
Update url tests to the latest upstream commit.

PR-URL: https://github.com/nodejs/node/pull/38435
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2021-04-30 00:04:32 +08:00
Jesse Chan
6ca785b951 tools: disable LTO for "v8_cppgc_shared" target
"PushAllRegistersAndIterateStack" is implemented in assembly and
called from "stack.cc" via 'extern "C"'. [1]

However, LTO does not work well with symbol usage from assembly. [2]

This change workarounds the issue by disabling LTO for the target.

With GCC 10 and "./configure --enable-lto", compilation succeeds
after this change.

[1] v8/v8@c10863153
[2] https://gcc.gnu.org/wiki/LinkTimeOptimizationFAQ#Symbol_usage_from_assembly_language

Refs: #35957
Refs: #38335
Signed-off-by: Jesse Chan <jc@linux.com>

PR-URL: https://github.com/nodejs/node/pull/38346
Refs: https://github.com/nodejs/node/issues/35957
Refs: https://github.com/nodejs/node/issues/38335
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2021-04-29 11:14:36 +00:00
James M Snell
32ade6997b doc: mark querystring api as legacy
Signed-off-by: James M Snell <jasnell@gmail.com>
Fixes: https://github.com/nodejs/node/issues/38231

PR-URL: https://github.com/nodejs/node/pull/38436
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2021-04-29 13:03:59 +02:00
Michael Dawson
c791019b36 doc: update node-api support matrix
Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: https://github.com/nodejs/node/pull/38424
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2021-04-28 18:18:43 -04:00
Qingyu Deng
50307ed4cd doc: add arguments for stream event of Http2Server and Http2SecureServer
PR-URL: https://github.com/nodejs/node/pull/37892
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-28 13:37:55 -07:00
Rich Trott
d037039a78 doc: indicate that abort tests do not generate core files
The key thing about the tests in `test/abort` is that tests in that
directory do not generate core files (thanks to testcfg.py). Make a note
of that in the test README.

PR-URL: https://github.com/nodejs/node/pull/38422
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2021-04-28 13:18:44 -07:00
Matteo Collina
1adcae96b5 doc: add try/catch in http2 respondWithFile example
PR-URL: https://github.com/nodejs/node/pull/38410
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-28 13:16:58 -07:00
Michaël Zasso
8b603697bc deps: patch V8 to 9.0.257.24
Refs: https://github.com/v8/v8/compare/9.0.257.21...9.0.257.24

PR-URL: https://github.com/nodejs/node/pull/38423
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-28 13:14:47 -07:00
Antoine du Hamel
7919ced0c9 lib: harden lint checks for globals
PR-URL: https://github.com/nodejs/node/pull/38419
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2021-04-28 13:13:23 -07:00
James M Snell
4af15df013 src: fix validation of negative offset to avoid abort
Fixes: https://github.com/nodejs/node/issues/24640
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/38421
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2021-04-28 11:04:42 -07:00
Rich Trott
896e5af1fd tools: remove fixer for non-ascii-character ESLint custom rule
The fixer for non-ascii-character does not typidally do the right thing.
It removes the entire node, not the offending character. I discovered
this when it removed the entire contents of a file and I wasn't sure
which auto-fix rule was doing it.

This commit adds a minimal test for the rule. The tests require that
auto-fix results be supplied, so if someone wants to re-add auto-fixing
to the rule, we'll have tests that it does the right thing.

PR-URL: https://github.com/nodejs/node/pull/38413
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-28 10:35:32 -07:00
James M Snell
346f0e99cd repl: document top level await limitation with const/let
Fixes: https://github.com/nodejs/node/issues/17669
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/38449
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2021-04-28 10:13:03 -07:00
Rich Trott
bdb6c597a7 debugger: apply automatic lint fixes for inspect_repl.js
For issues that ESLint can fix automatically, fix them.

PR-URL: https://github.com/nodejs/node/pull/38411
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2021-04-28 07:02:24 -07:00
Rich Trott
ea47bd2137 debugger: apply automatic lint fixes for _inspect.js
For issues that ESLint can fix automatically, fix them.

PR-URL: https://github.com/nodejs/node/pull/38411
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2021-04-28 07:02:23 -07:00
Antoine du Hamel
3d070d0073 tools: fix doc generation when version info is not available
Fixes: https://github.com/nodejs/node/issues/38391

PR-URL: https://github.com/nodejs/node/pull/38398
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2021-04-28 11:09:37 +02:00
Voltrex
32404359b6 typings: add JSDoc typings for fs
Added JSDoc typings for the `fs` lib module.

PR-URL: https://github.com/nodejs/node/pull/38306
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-04-27 15:06:12 -07:00
DeeDeeG
6e3ce658df tools: add _depot_tools to PATH (for V8 tests)
Ensures the `_depot_tools` dir bootstrapped during this script
is added to the PATH, before `ninja` is executed,
as `_depot_tools` already has a copy of `ninja` in it.
This means one less system requirement to be able to run this script.

(It seems like this was already intended to be on the PATH?)

Note: This script is used by the `test-v8` Makefile target.

PR-URL: https://github.com/nodejs/node/pull/38299
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-27 15:02:10 -07:00
DeeDeeG
d14d9f9edb doc: note the system requirements for V8 tests
The `test-v8` Makefile target still requires Python 2,
and it requires a full Xcode install on macOS.

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

PR-URL: https://github.com/nodejs/node/pull/38319
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2021-04-27 14:59:11 -07:00
James M Snell
5a0ed51a93 doc: minor clarification to pathObject
Signed-off-by: James M Snell <jasnell@gmail.com>
Fixes: https://github.com/nodejs/node/issues/36582

PR-URL: https://github.com/nodejs/node/pull/38437
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2021-04-27 14:56:09 -07:00
James M Snell
87aca074f9 doc: clarify that fs.Dir async iterator closes automatically
Signed-off-by: James M Snell <jasnell@gmail.com>
Fixes: https://github.com/nodejs/node/issues/35148

PR-URL: https://github.com/nodejs/node/pull/38438
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2021-04-27 14:55:26 -07:00
Nils Dralle
fa6d084dcb crypto: don't crash with some selfsigned certs
Refs: https://github.com/nodejs/node/issues/37757
Refs: https://github.com/nodejs/node/issues/37889

PR-URL: https://github.com/nodejs/node/pull/37990
Fixes: https://github.com/nodejs/node/issues/37757
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-27 14:36:01 -07:00
Arnold Zokas
b607373e61 doc: document new TCP_KEEPCNT and TCP_KEEPINTVL socket option defaults
PR https://github.com/nodejs/node/pull/32204 introduced new defaults for
the TCP keep-alive socket options (see deps/uv/src/unix/tcp.c):
- "TCP_KEEPCNT" now defaults to 10 on all platforms
- "TCP_KEEPINTVL" now defaults to 1 on all platforms

Previously, "TCP_KEEPCNT" and "TCP_KEEPINTVL" were not set explicitly
and OS-default values were used.

Fixes: https://github.com/nodejs/node/issues/38298
Refs: https://github.com/nodejs/node/pull/32204

PR-URL: https://github.com/nodejs/node/pull/38313
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-04-27 13:16:16 -07:00
Luigi Pinca
d432386f83 doc: do not mention TCP in the allowHalfOpen option description
The `allowHalfOpen` option works in the same way for both TCP and IPC
connections.

PR-URL: https://github.com/nodejs/node/pull/38360
Fixes: https://github.com/nodejs/node/issues/38307
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-04-27 19:21:00 +02:00
Rich Trott
50bbc4e403 doc: update message to match actual output
PR-URL: https://github.com/nodejs/node/pull/35271
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2021-04-27 09:04:33 -07:00
Rich Trott
751d215eb8 debugger: remove unused function argument
The `{colors: true}` removed here is ignored by the function it is being
sent to.

PR-URL: https://github.com/nodejs/node/pull/38400
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-27 08:59:38 -07:00
Rich Trott
01e0e3212d debugger: align message with Node.js standard
Node.js uses (or will use) _Ctrl+C_ with no spaces. To unify the
messages from inspect with other messages from the REPL and elsewhere,
make that change in node-inspect too.

PR-URL: https://github.com/nodejs/node/pull/38400
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-27 08:59:34 -07:00
Rafael Gonzaga
302cc9e92c debugger: add usage example for --port
PR-URL: https://github.com/nodejs/node/pull/38400
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-27 08:59:28 -07:00
James M Snell
ea0154814a perf_hooks: fix PerformanceObserver 'gc' crash
Signed-off-by: James M Snell <jasnell@gmail.com>
Fixes: https://github.com/nodejs/node/issues/38412

PR-URL: https://github.com/nodejs/node/pull/38414
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
2021-04-27 07:31:15 -07:00
Rich Trott
6f296b5729 test: move abort test from pummel to abort directory
test-abort-fatal-error is not resource intensive and would be better in
the abort directory than the pummel directory.

PR-URL: https://github.com/nodejs/node/pull/38396
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-27 07:22:03 -07:00
Antoine du Hamel
0c879cb7b8 benchmark: avoid using console.log()
PR-URL: https://github.com/nodejs/node/pull/38370
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-04-27 12:28:30 +02:00
Stephen Gallagher
47207e59f0 src: use %progbits instead of @progbits
While @progbits is preferred for most architectures, there are some
(notably 32-bit ARM) for which it does not. %progbits is effective
everywhere.

See https://bugzilla.redhat.com/show_bug.cgi?id=1950528 for more
details.

Related: https://github.com/nodejs/node/issues/17933
Related: https://github.com/nodejs/node/pull/37688

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>

PR-URL: https://github.com/nodejs/node/pull/38312
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2021-04-27 08:50:19 +02:00
Rod Vagg
9b878ecaf3 doc: request default snap track be updated for LTS
PR-URL: https://github.com/nodejs/node/pull/37708
Refs: https://github.com/nodejs/snap/pull/4
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Ash Cripps <acripps@redhat.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-27 08:47:53 +02:00
Rich Trott
7f56307a02 test: move slower tests into pummel and skip on slow devices
Move slower tests to pummel and skip on Raspberry Pi devices in CI.

Refs: https://github.com/nodejs/node/pull/34289#issuecomment-823655915

PR-URL: https://github.com/nodejs/node/pull/38395
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2021-04-26 21:21:38 -07:00
Rich Trott
4dc8e769a5 test: skip some pummel tests on slower machines
Skipped the longest-running pummel tests on the Raspberry Pi devices in
CI.

Refs: https://github.com/nodejs/node/pull/34289#issuecomment-823354459

PR-URL: https://github.com/nodejs/node/pull/38394
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: Filip Skokan <panva.ip@gmail.com>
2021-04-26 21:10:18 -07:00
Nitzan Uziely
09c97b8138 crypto: fix generateKeyPair type checks
Change saltLength, divisorLength, primeLength and generator
checks in generateKeyPair to int32 from uint32, to align
with c++ code.

fixes: https://github.com/nodejs/node/issues/38358

PR-URL: https://github.com/nodejs/node/pull/38364
Fixes: https://github.com/nodejs/node/issues/38358
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-26 11:55:45 -07:00
Michaël Zasso
3b86138f00 deps: patch V8 to 9.0.257.21
Refs: https://github.com/v8/v8/compare/9.0.257.19...9.0.257.21

PR-URL: https://github.com/nodejs/node/pull/38333
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-26 11:55:03 -07:00
Akhil Marsonya
00b6feec3e lib: fix and improve os typings
1. marked optional params as such
2. assigned default values using jsdoc conventions.

PR-URL: https://github.com/nodejs/node/pull/38316
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
2021-04-26 11:54:15 -07:00
Nitzan Uziely
f27b7cf95c fs: aggregate errors in fsPromises to avoid error swallowing
Add AggregateError support to fsPromises, instead of
swallowing errors if fs.close throws.

PR-URL: https://github.com/nodejs/node/pull/38259
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-26 11:53:25 -07:00
Darshan Sen
91d1b60d36 async_hooks,doc: replace process.stdout.fd with 1
This stops "RangeError: Maximum call stack size exceeded".

PR-URL: https://github.com/nodejs/node/pull/38382
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-26 11:51:48 -07:00
Antoine du Hamel
27beb386a8 crypto: fix scrypt keylen validation
Fixes: https://github.com/nodejs/node/issues/38381

PR-URL: https://github.com/nodejs/node/pull/38385
Reviewed-By: Nitzan Uziely <linkgoron@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2021-04-26 11:50:24 -07:00
cjihrig
59db84aba1 tools: update ESLint to 7.25.0
Update ESLint to 7.25.0

PR-URL: https://github.com/nodejs/node/pull/38378
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-26 11:49:07 -07:00
Antoine du Hamel
8c99045089 doc: mark process.hrtime() as legacy
PR-URL: https://github.com/nodejs/node/pull/38371
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bryan English <bryan@bryanenglish.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2021-04-26 11:44:58 -07:00
Antoine du Hamel
4e9ad206e2 benchmark: use process.hrtime.bigint()
PR-URL: https://github.com/nodejs/node/pull/38369
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-26 11:44:23 -07:00
takayama
0577fe3f26 doc: fix typo in worker_threads.md
"Buffer.alloc()" -> "Buffer.allocUnsafe()"

Buffer.alloc() does not use the internal Buffer pool.

PR-URL: https://github.com/nodejs/node/pull/38368
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-04-26 09:31:05 -07:00
Rich Trott
b2be410f53 tools: update markdown linter rules
Update remark-preset-lint-node to 2.2.0 which includes improved YAML
comment linting for our markdown files.

PR-URL: https://github.com/nodejs/node/pull/38384
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-26 09:19:08 -07:00
James M Snell
bbe24e2171 lib: add support for JSTransferable as a mixin
Adds a new `makeTransferable()` utility that can construct a
`JSTransferable` object that does not directly extend the
`JSTransferable` JavaScript class.

Because JavaScript does not support multiple inheritance, it is
not possible (without help) to implement a class that extends
both `JSTransferable` and, for instance, `EventTarget` without
incurring a significant additional complexity and performance
cost by making all `EventTarget` instances extend `JSTransferable`...

That is, we *don't* want:

```js
class EventTarget extends JSTransferable { ... }
```

The `makeTransferable()` allows us to create objects that are
backed internally by `JSTransferable` without having to actually
extend it by leveraging the magic of `Reflect.construct()`.

```js
const {
  JSTransferable,
  kClone,
  kDeserialize,
  kConstructor,
  makeTransferable,
} = require('internal/worker/js_transferable');

class E {
  constructor(b) {
    this.b = b;
  }
}

class F extends E {
  [kClone]() { /** ... **/ }
  [kDeserialize]() { /** ... **/ }

  static [kConstructor]() { return makeTransferable(F); }
}

const f = makeTransferable(F, 1);

f instanceof F;  // true
f instanceof E;  // true
f instanceof JSTransferable;  // false

const mc = new MessageChannel();
mc.port1.onmessage = ({ data }) => {
  data instanceof F;  // true
  data instanceof E;  // true
  data instanceof JSTransferable;  // false
};
mc.port2.postMessage(f);  // works!
```

The additional `internal/test/transfer.js` file is required for the
test because successfully deserializing transferable classes requires
that they be located in `lib/internal` for now.

Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/38383
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Khaidi Chu <i@2333.moe>
2021-04-26 07:55:48 -07:00