Matteo Collina
d5d3a03246
http: add regression test for smuggling content length
...
PR-URL: https://github.com/nodejs-private/node-private/pull/286
Reviewed-By: Beth Griggs <bgriggs@redhat.com >
2021-10-11 16:46:09 +01:00
Matteo Collina
0858587f21
http: add regression test for chunked smuggling
...
PR-URL: https://github.com/nodejs-private/node-private/pull/286
Reviewed-By: Beth Griggs <bgriggs@redhat.com >
2021-10-11 16:46:09 +01:00
Matteo Collina
1780bbc329
tls: validate "rejectUnauthorized: undefined"
...
Incomplete validation of rejectUnauthorized parameter (Low)
If the Node.js https API was used incorrectly and "undefined" was passed
in for the "rejectUnauthorized" parameter, no error was returned and
connections to servers with an expired certificate would have been
accepted.
CVE-ID: CVE-2021-22939
Refs: https://nvd.nist.gov/vuln/detail/CVE-2021-22939
Refs: https://hackerone.com/reports/1278254
PR-URL: https://github.com/nodejs-private/node-private/pull/276
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Akshay K <iit.akshay@gmail.com >
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: Richard Lau <rlau@redhat.com >
2021-08-09 17:19:09 +01:00
Akshay K
9cd1f53103
http2: add tests for cancel event while client is paused reading
...
Backport-PR-URL: https://github.com/nodejs/node/pull/39659
PR-URL: https://github.com/nodejs/node/pull/39622
Refs: https://github.com/nodejs/node/pull/39423
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Beth Griggs <bgriggs@redhat.com >
2021-08-09 17:17:36 +01:00
Gerhard Stoebich
364bf03a68
test: fix races in test-performance-eventlooputil
...
Fix two races in test-performance-eventlooputil resulting in a flaky
test.
elu1 was capture after start time t from spin look. If OS descides to
reschedule the process after capturing t but before getting elu for
>=50ms the spin loop is actually a nop. elu1 doesn't show this and as
a result elut3 = eventLoopUtilization(elu1) results in
elu3.active === 0.
Moving capturing of t after capturing t, just before the spin look
avoids this.
Similar if OS decides to shedule a different process between getting
the total elu from start and the diff elu showing the spin loop the
check to verify that total active time is long then the spin loop
fails.
Exchanging these statements avoids this race.
PR-URL: https://github.com/nodejs/node/pull/36028
Fixes: https://github.com/nodejs/node/issues/35309
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-03-29 14:10:41 +01:00
Joyee Cheung
86f34ee18c
v8: implement v8.stopCoverage()
...
Add a v8.stopCoverage() API to stop the coverage collection
started by NODE_V8_COVERAGE - this would be useful in
conjunction with v8.takeCoverage() if the user don't want
to emit the coverage at the process exit but still want
to collect it on demand at some point.
PR-URL: https://github.com/nodejs/node/pull/33807
Backport-PR-URL: https://github.com/nodejs/node/pull/36352
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Jiawen Geng <technicalcute@gmail.com >
Reviewed-By: Ben Coe <bencoe@gmail.com >
2021-03-17 20:36:04 +00:00
Joyee Cheung
8ddea3f16d
v8: implement v8.takeCoverage()
...
Add an v8.takeCoverage() API that allows the user to write the
coverage started by NODE_V8_COVERAGE to disk on demand.
The coverage can be written multiple times during the lifetime
of the process, each time the execution counter will be reset.
When the process is about to exit, one last coverage will
still be written to disk.
Also refactors the internal profiler connection code
so that we use the inspector response id to identify
the profile response instead of using an ad-hoc flag in C++.
PR-URL: https://github.com/nodejs/node/pull/33807
Backport-PR-URL: https://github.com/nodejs/node/pull/36352
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Jiawen Geng <technicalcute@gmail.com >
Reviewed-By: Ben Coe <bencoe@gmail.com >
2021-03-17 20:35:54 +00:00
Gerhard Stoebich
d7a4ccdf09
test: correct test-worker-eventlooputil
...
The active worker check compared the time from sending message till
response arrived from worker with the complete time the worker was
running till it responses to the spin request.
If sending back the message is slow for some reason the test fails.
Adapt the test to compare the time seen inside the worker with the
time read from main thread.
PR-URL: https://github.com/nodejs/node/pull/35891
Fixes: https://github.com/nodejs/node/issues/35844
Refs: https://github.com/nodejs/node/pull/35886
Refs: https://github.com/nodejs/node/pull/35664
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Backport-PR-URL: https://github.com/nodejs/node/pull/37165
2021-03-16 00:04:18 +00:00
Trevor Norris
eec7542781
worker: add eventLoopUtilization()
...
Allow calling eventLoopUtilization() directly on a worker thread:
const worker = new Worker('./foo.js');
const elu = worker.performance.eventLoopUtilization();
setTimeout(() => {
worker.performance.eventLoopUtilization(elu);
}, 10);
Add a new performance object on the Worker instance that will hopefully
one day hold all the other performance metrics, such as nodeTiming.
Include benchmarks and tests.
PR-URL: https://github.com/nodejs/node/pull/35664
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Backport-PR-URL: https://github.com/nodejs/node/pull/37165
2021-03-16 00:04:09 +00:00
Beth Griggs
a0b610450a
http: runtime deprecate legacy HTTP parser
...
The legacy HTTP parser, used by default in versions of Node.js prior to
12.0.0, is deprecated. The legacy HTTP parser cannot be guaranteed to be
supported after April 2021. This commit introduces a deprecation warning
for the legacy HTTP parser.
PR-URL: https://github.com/nodejs/node/pull/37603
Refs: https://github.com/nodejs/node/issues/31441
Reviewed-By: Richard Lau <rlau@redhat.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2021-03-08 13:08:46 +00:00
Anna Henningsen
6cef0e3678
src,test: add regression test for nested Worker termination
...
This adds a regression test for terminating a Worker inside which
another Worker is running.
PR-URL: https://github.com/nodejs/node/pull/32623
Refs: https://github.com/nodejs/node/pull/32531
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
2021-02-23 11:24:25 +00:00
Daniel Bevenius
922ada7713
http2: add unknownProtocol timeout
...
This commit add a configuration options named unknownProtocolTimeout
which can be specified to set a value for the timeout in milliseconds
that a server should wait when an unknowProtocol is sent to it. When
this happens a timer will be started and the if the socket has not been
destroyed during that time the timer callback will destoy it.
Refs: https://hackerone.com/reports/1043360
CVE-ID: CVE-2021-22883
PR-URL: https://github.com/nodejs-private/node-private/pull/246
Backport-PR-URL: https://github.com/nodejs-private/node-private/pull/250
Reviewed-By: Beth Griggs <bgriggs@redhat.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Michael Dawson <midawson@redhat.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2021-02-22 17:16:43 +00:00
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