David Halls
4ac8f37800
http2: check write not scheduled in scope destructor
...
Fixes: https://github.com/nodejs/node/issues/33156
PR-URL: https://github.com/nodejs/node/pull/36241
Backport-PR-URL: https://github.com/nodejs/node/pull/36355
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-02-09 22:14:22 -05:00
Stephen Belanger
e8a4e560ea
async_hooks: fix leak in AsyncLocalStorage exit
...
If exit is called and then run or enterWith are called within the
exit function, the als instace should not be added to the storageList
additional times. The correct behaviour is to remove the instance
from the storageList before executing the exit handler and then to
restore it after.
PR-URL: https://github.com/nodejs/node/pull/35779
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: Michael Dawson <midawson@redhat.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-02-09 22:14:21 -05:00
James M Snell
5b00de7d67
src: retain pointers to WriteWrap/ShutdownWrap
...
Avoids potential use-after-free when wrap req's are synchronously
destroyed.
CVE-ID: CVE-2020-8265
Fixes: https://github.com/nodejs-private/node-private/issues/227
PR-URL: https://github.com/nodejs-private/node-private/pull/230
Refs: https://hackerone.com/bugs?subject=nodejs&report_id=988103
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-24 11:27:08 +00:00
Matteo Collina
420244e4d9
http: unset F_CHUNKED on new Transfer-Encoding
...
Duplicate `Transfer-Encoding` header should be a treated as a single,
but with original header values concatenated with a comma separator. In
the light of this, even if the past `Transfer-Encoding` ended with
`chunked`, we should be not let the `F_CHUNKED` to leak into the next
header, because mere presence of another header indicates that `chunked`
is not the last transfer-encoding token.
Ref: https://github.com/nodejs-private/llhttp-private/pull/3
See: https://hackerone.com/bugs?report_id=1002188&subject=nodejs
CVE-ID: CVE-2020-8287
PR-URL: https://github.com/nodejs-private/node-private/pull/236
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com >
2020-12-23 16:01:52 +00:00
Richard Lau
4a30ac8c75
http: add test for http transfer encoding smuggling
...
Refs: https://github.com/nodejs-private/node-private/pull/228
Refs: https://hackerone.com/bugs?report_id=1002188&subject=nodejs
PR-URL: https://github.com/nodejs-private/node-private/pull/236
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com >
2020-12-23 16:01:44 +00:00
Luigi Pinca
b48473228c
events: assume an EventEmitter if emitter.on is a function
...
Assume that the `emitter` argument of `EventEmitter.once()` is an
`EventEmitter` if `emitter.on` is a function.
Refs: https://github.com/nodejs/node/commit/4b3654e923e7c3c2
Refs: https://github.com/websockets/ws/issues/1795
PR-URL: https://github.com/nodejs/node/pull/35818
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2020-11-16 11:58:06 -05:00
Myles Borins
18f01ddcb5
repl: improve static import error message in repl
...
Currently the error is rather ambiguous and does not inform folks that
static import is not supported in the repl. This overrides the default
error message with one that is more informative.
Closes: https://github.com/nodejs/node/issues/33576
PR-URL: https://github.com/nodejs/node/pull/33588
Fixes: https://github.com/nodejs/node/issues/33576
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2020-11-16 11:58:04 -05:00
Guy Bedford
354f358c1b
module: use Wasm CJS lexer when available
...
PR-URL: https://github.com/nodejs/node/pull/35583
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
2020-11-16 11:58:03 -05:00
Dmitry Gozman
a3e8829d4a
inspector: do not hardcode Debugger.CallFrameId in tests
...
Debugger.CallFrameId is defined as an opaque string [1].
Some tests currently hardcode the value, relying on
undocumented internal details of V8. This makes it hard
for V8 to change the internal representation.
We should instead use the reported call frame id from
the Debugger.paused event directly. This is how every
inspector client does it.
[1] https://chromedevtools.github.io/devtools-protocol/tot/Debugger/#type-CallFrameId
PR-URL: https://github.com/nodejs/node/pull/35570
Reviewed-By: Aleksei Koziatinskii <ak239spb@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-11-16 11:58:01 -05:00
ThakurKarthik
a6f58c0888
crypto: set env values in KeyObject Deserialize method
...
Fixes: https://github.com/nodejs/node/issues/35263
PR-URL: https://github.com/nodejs/node/pull/35416
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-11-16 11:57:57 -05:00
Leko
2e766a6adf
console: add Symbol.toStringTag property
...
Add Symbol.toStringTag property to console object to follow WPT changes
Update WPT status of console and the repl test case
Refs: https://github.com/web-platform-tests/wpt/pull/24717
PR-URL: https://github.com/nodejs/node/pull/35399
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-11-16 11:57:56 -05:00
Pooja D.P
fdc67ebf5f
test: replace annonymous functions with arrow
...
PR-URL: https://github.com/nodejs/node/pull/34921
Reviewed-By: Harshitha K P <harshitha014@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com >
2020-11-16 11:57:55 -05:00
Tobias Nießen
607f3c5d84
test: fix comment about DNS lookup test
...
PR-URL: https://github.com/nodejs/node/pull/35080
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-11-16 11:57:53 -05:00
Denys Otrishko
f22672de18
errors: improve ERR_INVALID_OPT_VALUE error
...
* use util.inspect for value presentation
* allow to optionally specify error reason
PR-URL: https://github.com/nodejs/node/pull/34671
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Mary Marchini <oss@mmarchini.me >
2020-11-16 11:57:53 -05:00
Guy Bedford
0f757bc2df
esm: use "node:" namespace for builtins
...
Backport-PR-URL: https://github.com/nodejs/node/pull/35757
PR-URL: https://github.com/nodejs/node/pull/35387
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2020-11-16 11:57:52 -05:00
Guy Bedford
9eb1fa1924
module: named exports for CJS via static analysis
...
Backport-PR-URL: https://github.com/nodejs/node/pull/35757
PR-URL: https://github.com/nodejs/node/pull/35249
Reviewed-By: Mary Marchini <oss@mmarchini.me >
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
2020-11-16 11:57:50 -05:00
delvedor
cce464513e
http: added scheduling option to http agent
...
In some cases, it is preferable to use a lifo scheduling strategy
for the free sockets instead of default one, which is fifo.
This commit introduces a scheduling option to add the ability
to choose which strategy best fits your needs.
Backport-PR-URL: https://github.com/nodejs/node/pull/35649
PR-URL: https://github.com/nodejs/node/pull/33278
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2020-11-16 11:57:49 -05:00
atian25@qq.com
d477e2e147
http: only set keep-alive when not exists
...
Backport-PR-URL: https://github.com/nodejs/node/pull/35623
PR-URL: https://github.com/nodejs/node/pull/35138
Fixes: https://github.com/nodejs/node/pull/34561
Reviewed-By: Ricky Zhou <0x19951125@gmail.com >
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
2020-11-16 11:57:49 -05:00
Robert Nagy
8a1091648c
stream: destroy wrapped streams on error
...
Stream should be destroyed and update state accordingly when
the wrapped stream emits error.
Does some additional cleanup with future TODOs that might be worth
looking into.
Backport-PR-URL: https://github.com/nodejs/node/pull/35557
PR-URL: https://github.com/nodejs/node/pull/34102
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-11-16 11:57:49 -05:00
rickyes
decfc2ae5c
fs: add .ref() and .unref() methods to watcher classes
...
Backport-PR-URL: https://github.com/nodejs/node/pull/35555
PR-URL: https://github.com/nodejs/node/pull/33134
Fixes: https://github.com/nodejs/node/issues/33096
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-11-16 11:57:49 -05:00
Luigi Pinca
02787ce5d1
test: add ALPNProtocols option to clientOptions
...
Without this, the session is destroyed with the following error
```
Error [ERR_HTTP2_ERROR]: Protocol error
at Http2Session.onSessionInternalError (internal/http2/core.js:756:26)
Emitted 'error' event on ClientHttp2Session instance at:
at emitClose (internal/http2/core.js:1010:10)
at internal/http2/core.js:1048:7
at finish (internal/streams/writable.js:731:5)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 'ERR_HTTP2_ERROR',
errno: -505
}
```
The test then calls `session.close()` which tries to write to a
destroyed socket. As a result, an unhandled `ECONNRESET` error is
emitted in the v12 release line.
Backport-PR-URL: https://github.com/nodejs/node/pull/34859
PR-URL: https://github.com/nodejs/node/pull/35482
Refs: https://github.com/nodejs/node/pull/34859
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-11-16 11:57:49 -05:00
David Halls
12d76b8e8e
tls: reset secureConnecting on client socket
...
secureConnecting is never set to false on client TLS sockets.
So if Http2Session constructor (in lib/internal/http2/core.js) is
called after secureConnect is emitted, then it will wrongly wait
for a secureConnect event.
This fix sets secureConnecting to false when a client TLS socket
has connected.
Backport-PR-URL: https://github.com/nodejs/node/pull/34859
PR-URL: https://github.com/nodejs/node/pull/33209
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
2020-11-16 11:57:49 -05:00
Bradley Farias
70768ce109
repl: give repl entries unique names
...
This is a workaround for the REPL for a problem when multiple of the
entries have the same source text
Fixes: https://github.com/nodejs/node/issues/1337
Refs: https://bugs.chromium.org/p/v8/issues/detail?id=10284
PR-URL: https://github.com/nodejs/node/pull/34372
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
2020-11-16 11:57:49 -05:00
Robert Nagy
f10d721737
http: reset headers timeout on headers complete
...
headers timeout should not occur *after* headers have been
received.
Fixes: https://github.com/nodejs/node/issues/35661
PR-URL: https://github.com/nodejs/node/pull/34578
Backport-PR-URL: https://github.com/nodejs/node/pull/35819
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Pranshu Srivastava <rexagod@gmail.com >
(cherry picked from commit da4d8de9d0 )
2020-11-16 11:57:48 -05:00
Carlos Lopez
b732c92e3d
http2: use and support non-empty DATA frame with END_STREAM flag
...
Adds support for reading from a stream where the final frame is a
non-empty DATA frame with the END_STREAM flag set, instead of hanging
waiting for another frame. When writing to a stream, uses a
END_STREAM flag on final DATA frame instead of adding an empty
DATA frame.
BREAKING: http2 client now expects servers to properly support
END_STREAM flag
Fixes: https://github.com/nodejs/node/issues/31309
Fixes: https://github.com/nodejs/node/issues/33891
Refs: https://nghttp2.org/documentation/types.html#c.nghttp2_on_data_chunk_recv_callback
Backport-PR-URL: https://github.com/nodejs/node/pull/34845
PR-URL: https://github.com/nodejs/node/pull/33875
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-11-16 11:57:48 -05:00
Denys Otrishko
e85ca7af43
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.
Backport-PR-URL: https://github.com/nodejs/node/pull/34845
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 >
2020-11-16 11:57:47 -05:00
Daniele Belardi
00aa935f5c
module: self referential modules in repl or -r
...
Load self referential modules from the repl and using the preload flag
`-r`. In both cases the base path used for resolution is the current
`process.cwd()`. Also fixes an internal cycle bug in the REPL exports
resolution.
PR-URL: https://github.com/nodejs/node/pull/32261
Backport-PR-URL: https://github.com/nodejs/node/pull/35385
Fixes: https://github.com/nodejs/node/issues/31595
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2020-10-01 11:32:40 -07:00
rickyes
3d1bdc254c
http: add maxTotalSockets to agent class
...
Add maxTotalSockets to determine how many sockets an agent can open.
Unlike maxSockets, The maxTotalSockets does not count by per origin.
PR-URL: https://github.com/nodejs/node/pull/33617
Backport-PR-URL: https://github.com/nodejs/node/pull/35396
Fixes: https://github.com/nodejs/node/issues/31942
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-09-29 00:01:11 +02:00
rickyes
2f67e99a0b
test: add arrayOfStreams to pipeline
...
PR-URL: https://github.com/nodejs/node/pull/34156
Backport-PR-URL: https://github.com/nodejs/node/pull/35388
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-09-28 10:59:41 +02:00
Anna Henningsen
8d0c21fd24
util: restrict custom inspect function + vm.Context interaction
...
When `util.inspect()` is called on an object with a custom inspect
function, and that object is from a different `vm.Context`,
that function will not receive any arguments that access
context-specific data anymore.
PR-URL: https://github.com/nodejs/node/pull/33690
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2020-09-28 10:59:38 +02:00
Evan Lucas
4a2accb3d0
internal: rename error-serdes for consistency
...
All other JavaScript files in lib use snake case, so make this
one consistent.
PR-URL: https://github.com/nodejs/node/pull/33793
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2020-09-28 10:59:38 +02:00
Anna Henningsen
3598056ac1
test: add vm crash regression test
...
Refs: https://github.com/nodejs/node/issues/34606
PR-URL: https://github.com/nodejs/node/pull/34673
Reviewed-By: Jiawen Geng <technicalcute@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-09-28 10:59:36 +02:00
Anna Henningsen
6ee800f0c3
buffer: also alias BigUInt methods
...
These were overlooked in 5864fca7bc because of the extra
`Big` in the name. :)
Refs: https://github.com/nodejs/node/pull/34729
PR-URL: https://github.com/nodejs/node/pull/34960
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2020-09-28 10:59:35 +02:00
Anna Henningsen
139442c34e
worker: add public method for marking objects as untransferable
...
We currently mark a number of `ArrayBuffer`s as not transferable,
including the `Buffer` pool and ones with finalizers provided
by C++ addons.
There is no good reason to assume that userland code might not
encounter similar problems, for example when doing `ArrayBuffer`
pooling similar to ours. Therefore, provide an API that lets
userland code also mark objects as not transferable.
PR-URL: https://github.com/nodejs/node/pull/33979
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
2020-09-28 10:59:35 +02:00
Anna Henningsen
44864d7385
worker: do not crash when JSTransferable lists untransferable value
...
This can currently be triggered when posting a closing FileHandle.
Refs: https://github.com/nodejs/node/pull/34746#issuecomment-673675333
PR-URL: https://github.com/nodejs/node/pull/34766
Backport-PR-URL: https://github.com/nodejs/node/pull/34814
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-09-28 10:59:34 +02:00
Tobias Nießen and Anna Henningsen
b828560908
crypto: allow KeyObjects in postMessage
...
This change allows sharing KeyObjects between threads via postMessage.
The receiver acquires a new KeyObject and a new KeyObjectHandle, but
refers to the same KeyObjectData:
+-------------------+
| NativeKeyObject 1 | ------------------------------------------+
+-------------------+ |
^ |
extends |
| |
+-------------------+ +-------------------+ |
| KeyObject 1 (JS) | -> | KeyObjectHandle 1 | --------------+ |
+-------------------+ +-------------------+ | |
| |
| |
| |
| |
| |
+-------------------+ | |
| NativeKeyObject 2 | ------------------------------------+ | |
+-------------------+ | | |
^ | | |
extends | | |
| | | |
+-------------------+ +-------------------+ | | |
| KeyObject 2 (JS) | -> | KeyObjectHandle 2 | --------+ | | |
+-------------------+ +-------------------+ | | | |
| | | |
| | | |
| | | |
| | | |
| | | |
+-------------------+ | | | |
| NativeKeyObject 3 | ------------------------------+ | | | |
+-------------------+ | | | | |
^ | | | | |
extends | | | | |
| v v v v v
+-------------------+ +-------------------+ +---------------+
| KeyObject 3 (JS) | -> | KeyObjectHandle 3 | -> | KeyObjectData |
+-------------------+ +-------------------+ +---------------+
Co-authored-by: Anna Henningsen <anna@addaleax.net >
PR-URL: https://github.com/nodejs/node/pull/33360
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-09-28 10:59:32 +02:00
Anna Henningsen
dafa380732
worker: emit 'messagerror' events for failed deserialization
...
This is much nicer than just treating exceptions as uncaught, and
enables reporting of exceptions from the internal C++ deserialization
machinery.
PR-URL: https://github.com/nodejs/node/pull/33772
Backport-PR-URL: https://github.com/nodejs/node/pull/33965
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2020-09-28 10:59:30 +02:00
Anna Henningsen
dd51ba3f93
worker,fs: make FileHandle transferable
...
Allow passing `FileHandle` instances in the transfer list
of a `.postMessage()` call.
PR-URL: https://github.com/nodejs/node/pull/33772
Backport-PR-URL: https://github.com/nodejs/node/pull/33965
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2020-09-28 10:59:30 +02:00
Anna Henningsen
0d35eaa034
worker: allow passing JS wrapper objects via postMessage
...
Enable JS wrapper objects to be used as transferable or cloneable
objects in `postMessage()` calls, by having them extend a C++-backed
class.
This requires a few internal changes:
- This commit adds the possibility for transferred objects to
read/write JS values at the end of the serialization/deserialization
phases.
- This commit adds the possibility for transferred objects to list
sub-transferables, e.g. typically the public JS wrapper class
would list its C++ handle in there.
- This commit adds usage of `BaseObject` in a few more places, because
now during deserialization weakly held objects can also be involved,
in addition to `MessagePort`s.
PR-URL: https://github.com/nodejs/node/pull/33772
Backport-PR-URL: https://github.com/nodejs/node/pull/33965
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2020-09-27 12:32:00 +02:00
Anna Henningsen
b4819dba5c
worker: add option to track unmanaged file descriptors
...
Add a public option for Workers which adds tracking for raw
file descriptors, as currently, those resources are not cleaned
up, unlike e.g. `FileHandle`s.
PR-URL: https://github.com/nodejs/node/pull/34303
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2020-09-27 11:57:39 +02:00
Maël Nison
a19933f7fc
fs: implement lutimes
...
PR-URL: https://github.com/nodejs/node/pull/33399
Backport-PR-URL: https://github.com/nodejs/node/pull/35320
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Jiawen Geng <technicalcute@gmail.com >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
2020-09-25 16:50:48 +02:00
Anna Henningsen
b7e4d5fc0e
src: shutdown libuv before exit()
...
This ensures that no operations will be running on the libuv
threadpool, which is important because they may run into race
conditions with the global destructors being triggered from
`exit()`, such as in the added test example here.
PR-URL: https://github.com/nodejs/node/pull/35021
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-09-23 22:34:08 +02:00
Anna Henningsen
5e9f0cfa62
worker: fix --abort-on-uncaught-exception handling
...
The `set_abort_on_uncaught_exception(false)` line was supposed to
prevent aborting when running Workers in
`--abort-on-uncaught-exception` mode, but it was incorrectly set
and not checked properly in the should-abort callback.
PR-URL: https://github.com/nodejs/node/pull/34724
Backport-PR-URL: https://github.com/nodejs/node/pull/34815
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Mary Marchini <oss@mmarchini.me >
2020-09-23 22:34:08 +02:00
Anna Henningsen
9173b09445
worker: add stack size resource limit option
...
Add `stackSizeMb` to the `resourceLimit` option group.
Refs: https://github.com/nodejs/node/pull/31593#issuecomment-619633820
PR-URL: https://github.com/nodejs/node/pull/33085
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2020-09-23 22:03:26 +02:00
Anna Henningsen
29620c41fb
src: use env->RequestInterrupt() for inspector MainThreadInterface
...
This simplifies the code significantly, and removes the dependency of
the inspector code on the availability of a `MultiIsolatePlatform`
(by removing the dependency on a platform altogether).
It also fixes a memory leak that occurs when `RequestInterrupt()`
is used, but the interrupt handler is never called before the Isolate
is destroyed.
One downside is that this leads to a slight change in timing, because
inspector messages are not dispatched in a re-entrant way. This means
having to harden one test to account for that possibility by making
sure that the stack is always clear through a `setImmediate()`.
This does not affect the assertion made by the test, which is that
messages will not be delivered synchronously while other code is
executing.
https://github.com/nodejs/node/issues/32415
Backport-PR-URL: https://github.com/nodejs/node/pull/35241
PR-URL: https://github.com/nodejs/node/pull/32523
Reviewed-By: Matheus Marchini <mat@mmarchini.me >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-09-23 20:07:57 +02:00
Anna Henningsen
1066341cd9
src: initialize inspector before RunBootstrapping()
...
This is necessary for `--inspect-brk-node` to work, and for the
inspector to be aware of scripts created before bootstrapping.
Fixes: https://github.com/nodejs/node/issues/32648
Refs: https://github.com/nodejs/node/pull/30467#discussion_r396879908
Backport-PR-URL: https://github.com/nodejs/node/pull/35241
PR-URL: https://github.com/nodejs/node/pull/32672
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-09-23 20:07:56 +02:00
Anna Henningsen
b47172d2ed
doc,test: specify and test CLI option precedence rules
...
Refs: https://github.com/nodejs/node/pull/35098#issuecomment-689051526
PR-URL: https://github.com/nodejs/node/pull/35106
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
2020-09-22 23:48:17 +02:00
Tobias Nießen
d60c487c53
test: remove setMaxListeners in test-crypto-random
...
This appears to be a remnant from
413d38c43b .
PR-URL: https://github.com/nodejs/node/pull/35079
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-09-22 23:48:14 +02:00
Rich Trott
2b7273b2ad
crypto: improve invalid arg type message for randomInt()
...
Use "must be a safe integer" rather than "must be safe integer". I
believe the former is more easily understood/clear.
PR-URL: https://github.com/nodejs/node/pull/35089
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2020-09-22 23:48:13 +02:00
Rich Trott
bf5a85b43a
crypto: improve randomInt out-of-range error message
...
Previously, the crypto.randomInt() message when "max" was less than or
equal to "min" made it sound like the lower bound for "max" was
hard-coded. Make it clear that it is instead dynamic based on the value
of "min".
For crypto.randomInt(10,0):
Before:
RangeError [ERR_OUT_OF_RANGE]: The value of "max" is out of range. It
must be > 10. Received 0
After:
RangeError [ERR_OUT_OF_RANGE]: The value of "max" is out of range. It
must be greater than the value of "min" (10). Received 0
PR-URL: https://github.com/nodejs/node/pull/35088
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2020-09-22 23:48:12 +02:00