Commit graph

249 commits

Author SHA1 Message Date
Yagiz Nizipli
317d2450f9
src: modernize likely/unlikely hints
PR-URL: https://github.com/nodejs/node/pull/55155
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2024-09-30 18:04:16 +00:00
Maël Nison
6c6562ce8b
http2: expose nghttp2_option_set_stream_reset_rate_limit as an option
PR-URL: https://github.com/nodejs/node/pull/54875
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2024-09-30 09:52:08 +00:00
Rafael Gonzaga
532767b71d
src: cache invariant code motion
PR-URL: https://github.com/nodejs/node/pull/53879
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Tim Perry <pimterry@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2024-07-21 23:18:57 +00:00
James M Snell
d335487e3f src, deps: add nbytes library
Projects that seek to implement Node.js compatible APIs end up
needed to reproduce various bits of functionality internally in
order to faithfully replicate the Node.js behaviors. This is
particularly true for things like byte manipulation, base64 and
hex encoding, and other low-level operations. This change
proposes moving much of this low-level byte manipulation code
out of nodejs/src and into a new `nbytes` library. Initially this
new library will exist in the `deps` directory but the intent is
to spin out a new separate repository to be its home in the future.
Doing so will allow other projects to use the nbytes library with
exactly the same implementation as Node.js.

This commit moves only the byte swapping and legacy base64 handling
code. Additional commits will move additional byte manipulation
logic into the library.

PR-URL: https://github.com/nodejs/node/pull/53507
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2024-06-21 07:38:37 -07:00
Michaël Zasso
c93e256ee7
src: use args.This() instead of Holder
The latter is deprecated in V8.

Refs: http://crbug.com/333672197
PR-URL: https://github.com/nodejs/node/pull/53474
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
2024-06-18 16:02:42 +00:00
Michaël Zasso
ec1550407b
src: stop using v8::BackingStore::Reallocate
It's being deprecated by V8.
Explicitly allocate a new ArrayBuffer and copy the data when needed
instead.

Fixes: https://github.com/nodejs/node/issues/52234
Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/52292
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2024-04-05 09:20:10 +00:00
RafaelGSS
b25b5aca96 src: ensure to close stream when destroying session
Co-Authored-By: Anna Henningsen <anna@addaleax.net>
PR-URL: https://github.com/nodejs-private/node-private/pull/561
Fixes: https://hackerone.com/reports/2319584
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
CVE-ID: CVE-2024-27983
2024-04-03 11:37:07 -03:00
Marten Richter
bf37d4be69
http2: receive customsettings
This commit gives node.js the ability to also receive custom settings,
in addition to sending, them which was implemented before.
The custom settings received are limited to setting ids,
that were specified before, when creating the session eithers through
the server or the client.

PR-URL: https://github.com/nodejs/node/pull/51323
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2024-01-07 17:33:52 +00:00
Marten Richter
2c571c650a
http2: addtl http/2 settings
Currently, node.js http/2 is limited in sending SETTINGs,
that are currently implemented by nghttp2.
However, nghttp2 has the ability to send arbitary SETTINGs,
that are not known beforehand.
This patch adds this feature including a fall back mechanism,
if a SETTING is implemented in a later nghttp2 or node version.

Fixes: https://github.com/nodejs/node/issues/1337
PR-URL: https://github.com/nodejs/node/pull/49025
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2023-12-18 09:18:25 +00:00
Joyee Cheung
6391b3b95d src: use per-realm GetBindingData() wherever applicable
This reduce the number of embedder slot accesses and also removes
the assumption in a few binding methods that the current realm is
the principal realm of the current environment (which is not true
for shadow realms).

PR-URL: https://github.com/nodejs/node/pull/49007
Refs: https://github.com/nodejs/node/pull/48836
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-08-16 02:32:50 +00:00
Joyee Cheung
faefe560ef
src: remove ContextEmbedderIndex::kBindingDataStoreIndex
We can now get the binding data through the reference to the
realm directly, so remove it from the context embedder data
slot.

PR-URL: https://github.com/nodejs/node/pull/48836
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2023-07-26 13:26:08 +00:00
Tobias Nießen
259ea3ed59
http2: improve nghttp2 error callback
The http2 implementation uses the deprecated function
nghttp2_session_callbacks_set_error_callback, which does not supply an
error code but only an error message. This so far forced node's error
callback to rely on the error message in order to distinguish between
different errors, which is fragile and inefficient.

Use the newer nghttp2_session_callbacks_set_error_callback2 function
instead, which is not deprecated and which provides the exact error code
to node's error callback.

PR-URL: https://github.com/nodejs/node/pull/47840
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-05-05 14:03:39 +00:00
Tobias Nießen
4f5bb1a75a
src: use v8::Boolean(b) over b ? True() : False()
Simplify existing code by using v8::Boolean::New() instead of equivalent
expressions that contain ternary operators.

PR-URL: https://github.com/nodejs/node/pull/47554
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2023-04-16 18:26:06 +00:00
ywave620
18e1f3c3a3
src,http2: ensure cleanup if a frame is not sent
Call to JS and close the session if a frame is not sent
even there is no frameError listener registered by user.

PR-URL: https://github.com/nodejs/node/pull/47244
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2023-03-30 12:40:45 +00:00
Joyee Cheung
8b2126f63f
src: move AliasedBuffer implementation to -inl.h
Drive-by: Replace the SFINAE with a static_assert because we don't
have (or need) an implementation for non-scalar AliasedBufferBase
otherwise. Add forward declarations to memory_tracker.h now that
aliased-buffer.h no longer includes util-inl.h.

PR-URL: https://github.com/nodejs/node/pull/46817
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2023-03-01 17:45:02 +01:00
Chengzhong Wu
ca07abab53
src: per-realm binding data
Binding data is inherited from BaseObject and created in a specific
realm. They need to be tracked on a per-realm basis so that they can
be released properly when a realm is disposed.

PR-URL: https://github.com/nodejs/node/pull/46556
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2023-02-21 22:43:25 +00:00
Rich Trott
d1b29b4661
Revert "src: let http2 streams end after session close"
This reverts commit dee882e94f.
Moved the test that demonstrated what this commit was fixing to the
`known_issues` folder.

Fixes: https://github.com/nodejs/node/issues/46234
PR-URL: https://github.com/nodejs/node/pull/46721
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2023-02-21 12:46:21 +00:00
Chengzhong Wu
bb40507f3e
src: distinguish env stopping flags
`Environment::FreeEnvironment` creates a
`DisallowJavascriptExecutionScope`, so the flag
`Environment::can_call_into_js()` should also be set as `false`. As
`Environment::can_call_into_js_` is a simple boolean flag, it should not
be accessed off-threads.

PR-URL: https://github.com/nodejs/node/pull/45907
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2023-01-14 09:59:17 +00:00
legendecas
71ff89f929
src: rename internal module declaration as internal bindings
This is a continuation of the name reification on the internal bindings.

Renames NODE_MODULE_CONTEXT_AWARE_INTERNAL and
NODE_MODULE_EXTERNAL_REFERENCE to NODE_BINDING_CONTEXT_AWARE_INTERNAL
and NODE_BINDING_EXTERNAL_REFERENCE respectively.

PR-URL: https://github.com/nodejs/node/pull/45551
Refs: https://github.com/nodejs/node/issues/44036
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2022-11-29 00:23:08 +08:00
Michaël Zasso
2a7635feb2
src: use qualified std::move call in node_http2
Also iwyu in that file.

Closes: https://github.com/nodejs/node/issues/45543
PR-URL: https://github.com/nodejs/node/pull/45555
Fixes: https://github.com/nodejs/node/issues/45543
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2022-11-23 08:14:26 +00:00
Santiago Gimeno
5e74cb6076 src: print nghttp2 logs when using --debug-nghttp2
PR-URL: https://github.com/nodejs/node/pull/45209
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2022-11-01 20:05:23 +00:00
Santiago Gimeno
71bdecb908
src: let http2 streams end after session close
After the stream has been marked as closed by the nghttp2 stack, there
might be still pending data to be sent: trailing headers is an example
of this. In that case, avoid reentering the nghttp2 stack synchronously
to allow the data to be written before actually closing the stream.

Fixes: https://github.com/nodejs/node/issues/42713
PR-URL: https://github.com/nodejs/node/pull/45153
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2022-10-27 09:34:45 +00:00
Santiago Gimeno
5374e15d24
http2: improve session close/destroy procedures
Don't destroy the socket when closing the session but let it end
gracefully.
Also, when destroying the session, on Windows, we would get ECONNRESET
errors, make sure we take those into account in our tests.

PR-URL: https://github.com/nodejs/node/pull/45115
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2022-10-26 09:16:00 +00:00
Santiago Gimeno
67828d58fb
http2: fix crash on Http2Stream::diagnostic_name()
It can happen that the Http2Stream::session_ has already been deleted
when the Http2Stream destructor is called, causing `diagnostic_name()`
to crash. Observed when running some http2 tests on Windows with the
debug logs activated.

PR-URL: https://github.com/nodejs/node/pull/45123
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2022-10-25 13:23:57 +00:00
ywave620
78d280a768
src,stream: improve DoWrite() and Write()
Clarify StreamResource::DoWrite() interface definition.
Fix error-prone Http2Stream::DoWrite().
Change StreamBase::Write() to allow caller to avoid
inefficient write behavior.

PR-URL: https://github.com/nodejs/node/pull/44434
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2022-10-10 11:00:23 +00:00
Santiago Gimeno
d2cf01d756
src: avoid using v8 on Isolate termination
Fix multiple instances of those uncovered while running the tests on
debug builds.

Fixes: https://github.com/nodejs/node-v8/issues/227
PR-URL: https://github.com/nodejs/node/pull/44669
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2022-09-21 13:35:25 +00:00
legendecas
a7e5b413ef
src: split property helpers from node::Environment
PR-URL: https://github.com/nodejs/node/pull/44056
Refs: https://github.com/nodejs/node/issues/42528
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Feng Yu <F3n67u@outlook.com>
2022-08-02 00:01:02 +08:00
legendecas
dabda03ea9
src: per-environment time origin value
According to https://html.spec.whatwg.org/#environment-settings-object,
the timeOrigin is a per-environment value. Worker's timeOrigin is the
time when the worker is created.

PR-URL: https://github.com/nodejs/node/pull/43781
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2022-07-16 16:46:40 +08:00
theanarkh
cb4a558eeb
perf_hooks: fix start_time of perf_hooks
PR-URL: https://github.com/nodejs/node/pull/43069
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2022-05-26 22:13:31 +08:00
Darshan Sen
f91dcc205d
src: delete AllocatedBuffer
Since all its uses are now gone, it's time to say goodbye to
AllocatedBuffer.

Refs: https://github.com/nodejs/node/pull/39941
Signed-off-by: Darshan Sen <raisinten@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/43008
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2022-05-13 15:24:13 +01:00
Michael Dawson
33cbdb33e4 src: address 3 useless call coverity warnings
Fix the last 3 useless call reports from coverity

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: https://github.com/nodejs/node/pull/42426
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2022-03-29 16:49:02 -04:00
Michael Dawson
82342c2a54
http2: fix potential integer overflow
Fix report from coverity on potential integer overflow
in http2.

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: https://github.com/nodejs/node/pull/42248
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2022-03-10 08:53:05 +00:00
Rafael Silva
db6490cba2
http2: close stream and session on frameError
PR-URL: https://github.com/nodejs/node/pull/42147
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2022-03-02 12:53:11 +00:00
Anna Henningsen
b51eba422f
src: remove separate definitions for static constexpr members
This is no longer necessary (and actually deprecated) since C++17.

PR-URL: https://github.com/nodejs/node/pull/41755
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2022-02-11 16:42:09 +00:00
Rafael Silva
f98a785dab
http2: fix memory leak on nghttp2 hd threshold
PR-URL: https://github.com/nodejs/node/pull/41502
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2022-01-28 16:28:46 +00:00
Darshan Sen
f8035ecbbd src: remove usage of AllocatedBuffer from node_http2
Signed-off-by: Darshan Sen <darshan.sen@postman.com>

PR-URL: https://github.com/nodejs/node/pull/40584
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2021-10-30 08:46:10 +00:00
Akshay K
60fd5d4be1
http2: update handling of rst_stream with error code NGHTTP2_CANCEL
The PR updates the handling of rst_stream frames and adds all streams
to the pending list on receiving rst frames with the error code
NGHTTP2_CANCEL.

The changes will remove dependency on the stream state that may allow
bypassing the checks in certain cases. I think a better solution is to
delay streams in all cases if rst_stream is received for the cancel
events.

The rst_stream frames can be received for protocol/connection error as
well it should be handled immediately. Adding streams to the pending
list in such cases may cause errors.

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-06 14:39:55 +01:00
Akshay K
c0f10006c8 http2: on receiving rst_stream with cancel code add it to pending list
PR-URL: https://github.com/nodejs/node/pull/39423
Fixes: https://github.com/nodejs/node/issues/38964
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2021-07-20 13:31:27 +02:00
bl-ue
11e77e44f9 src: fix typos
PR-URL: https://github.com/nodejs/node/pull/38845
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
2021-06-01 12:04:16 +02:00
Anna Henningsen
9d07c0a20b
http2: add specific error code for custom frames
As suggested in
https://github.com/nodejs/node/issues/37849#issuecomment-805049586
improve the error presented when encountering a large number of
invalid frames by giving this situation a specific error code (which we
should have had from the beginning).

PR-URL: https://github.com/nodejs/node/pull/37936
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2021-04-01 12:34:55 -07:00
Anna Henningsen
87aa3f1add
http2: treat non-EOF empty frames like other invalid frames
Use the existing mechanism that we have to keep track of invalid frames
for treating this specific kind of invalid frame.

The commit that originally introduced this check was 695e38be69,
which was supposed to proected against CVE-2019-9518, which in turn
was specifically about a *flood* of empty data frames. While these are
still invalid frames either way, it makes sense to be forgiving here
and just treat them like other invalid frames, i.e. to allow a small
(configurable) number of them.

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

PR-URL: https://github.com/nodejs/node/pull/37875
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2021-03-26 20:51:57 +01:00
James M Snell
f3eb224c83
perf_hooks: complete overhaul of the implementation
* Update the user timing implementation to conform to
  User Timing Level 3.
* Reimplement user timing and timerify with pure JavaScript
  implementations
* Simplify the C++ implementation for gc and http2 perf
* Runtime deprecate additional perf entry properties
  in favor of the standard detail argument
* Disable the `buffered` option on PerformanceObserver,
  all entries are queued and dispatched on setImmediate.
  Only entries with active observers are buffered.
* This does remove the user timing and timerify
  trace events. Because the trace_events are still
  considered experimental, those can be removed without
  a deprecation cycle. They are removed to improve
  performance and reduce complexity.

Old: `perf_hooks/usertiming.js n=100000: 92,378.01249733355`
New: perf_hooks/usertiming.js n=100000: 270,393.5280638482`

PR-URL: https://github.com/nodejs/node/pull/37136
Refs: https://github.com/nodejs/diagnostics/issues/464
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2021-02-22 08:46:11 -08:00
James M Snell
4a19cc8947
perf_hooks: introduce createHistogram
Adds a new `perf_hooks.createHistogram()` API for creating histogram
instances that allow user recording.

Makes Histogram instances cloneable via MessagePort. This allows, for
instance, an event loop delay monitor to be running on the main thread
while the histogram data can be monitored actively from a worker thread.

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

PR-URL: https://github.com/nodejs/node/pull/37155
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2021-02-14 13:03:49 -08:00
Joyee Cheung
1b7531cdeb
src: rename binding_data_name to type_name in BindingData
Previously, this was a per-class string constant for BindingData
which is used as keys for identifying these objects in the binding
data map. These are just type names of the BindingData.
This patch renames the variable to type_name so that
we can generalize this constant for other BaseObjects and use
it for debugging and logging the types of other BaseObjects.

PR-URL: https://github.com/nodejs/node/pull/37112
Refs: https://github.com/nodejs/node/pull/36943
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
2021-02-08 14:00:31 +08:00
James M Snell
28fe1ef635
src: reduce duplicated boilerplate with new env utility fn
Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/36536
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2021-01-03 12:58:09 -08:00
David Halls
83166fb86c 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
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-12-01 06:47:16 -08:00
zhangyongsheng
c0ac692ba7 http2: allow setting the local window size of a session
PR-URL: https://github.com/nodejs/node/pull/35978
Fixes: https://github.com/nodejs/node/issues/31084
Refs: https://github.com/nodejs/node/pull/26962
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
2020-11-11 23:14:56 +08:00
Momtchil Momtchev
75202d971d http2: reinject data received before http2 is attached
Reinject the data already received from the TLS
socket when the HTTP2 client is attached with a
delay

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

PR-URL: https://github.com/nodejs/node/pull/35678
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Alba Mendez <me@alba.sh>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
2020-10-25 10:29:45 +00:00
Momtchil Momtchev
70834250e8 http2: remove unsupported %.* specifier
The debug sprintf doesn't support %.* specifiers

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

PR-URL: https://github.com/nodejs/node/pull/35694
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
2020-10-24 14:26:50 +00:00
Anna Henningsen
78e58755f7
http2,tls: store WriteWrap using BaseObjectPtr
Create weak `WriteWrap` and `ShutdownWrap` objects, and when
referencing them in C++ is necessary, use `BaseObjectPtr<>`
instead of plain pointers to keep these objects from being
garbage-collected.

This solves issues that arise when the underlying `StreamBase`
instance is weak, but the `WriteWrap` or `ShutdownWrap` instances
are not; in that case, they would otherwise potentially stick
around in memory after the stream that they originally belong
to is long gone.

It probably makes sense to use `BaseObjectptr<>` more extensively
in `StreamBase` in the long run as well.

PR-URL: https://github.com/nodejs/node/pull/35488
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2020-10-06 13:26:33 +02:00