James M Snell
c973d503e0
tls: add ability to get cert/peer cert as X509Certificate object
...
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/37070
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
2021-02-02 09:39:27 -08:00
James Addison
a0c0875e42
src: read exactly two tokens from Linux THP sysfs config
...
There was an unexpected and hard-to-spot issue here:
the /sys/kernel/mm/transparent_hugepage/enabled file contains three
entries, and the std::ifstream reader was reading two values on each
loop iteration, resulting in incorrect behaviour.
Fixes: https://github.com/nodejs/node/issues/37064
PR-URL: https://github.com/nodejs/node/pull/37065
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-02-02 18:54:09 +05:30
Joyee Cheung
638fb48911
src: expose BaseObject::kInternalFieldCount in post-mortem metadata
...
So that the debugger does not have to hard-code the number of
internal fields of BaseObjects.
PR-URL: https://github.com/nodejs/node/pull/37111
Refs: https://github.com/nodejs/node/pull/36943
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-02-02 01:57:05 +08:00
James M Snell
c3d6d50309
quic: remove quic
...
PR-URL: https://github.com/nodejs/node/pull/37067
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Michael Dawson <midawson@redhat.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2021-01-30 07:49:28 -08:00
Tobias Nießen
0a993e1f24
src: fix dead code in RandomPrimeTraits
...
PR-URL: https://github.com/nodejs/node/pull/37083
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2021-01-29 21:09:21 +01:00
Tobias Nießen
c9992a0d66
crypto: fix encrypted private -> public import
...
PR-URL: https://github.com/nodejs/node/pull/37056
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2021-01-27 15:42:04 +01:00
Filip Skokan
8b65004193
crypto: generateKeyPair('ec') should not support NODE-ED* and NODE-X*
...
Fixes https://github.com/nodejs/node/issues/37055
PR-URL: https://github.com/nodejs/node/pull/37063
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
2021-01-27 14:55:03 +01:00
James M Snell
da3a9486a8
buffer: avoid creating the backing store in the thread
...
Fixes: https://github.com/nodejs/node/issues/37030
PR-URL: https://github.com/nodejs/node/pull/37052
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-01-26 19:12:00 -08:00
James M Snell
bb13469acb
crypto: add generatePrime/checkPrime
...
APIs for generating and checking pseudo-random primes
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/36997
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2021-01-26 07:37:18 -08:00
Tobias Nießen
7394311a2e
src: rename crypto_ecdh.(h|cc) to crypto_ec.(h|cc)
...
PR-URL: https://github.com/nodejs/node/pull/37048
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2021-01-25 08:11:25 -08:00
Tyler Ang-Wanek
bf79987433
src: mark internally exported functions as explicitly internal
...
PR-URL: https://github.com/nodejs/node/pull/37000
Fixes: https://github.com/nodejs/node/issues/36349
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-24 11:12:06 -08:00
Tyler Ang-Wanek
1fe571aa0c
src: inline AsyncCleanupHookHandle in headers
...
Fixes: https://github.com/nodejs/node/issues/36349
PR-URL: https://github.com/nodejs/node/pull/37000
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-24 11:12:03 -08:00
ExE Boss and Antoine du Hamel
3ec71143f2
lib: support returning Safe collections from C++
...
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/36989
Refs: https://github.com/nodejs/node/pull/36652
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-22 19:49:04 -08:00
Joyee Cheung
e3e054d020
src: use BaseObject::kInteralFieldCount in Blob
...
Instead of hard-coding the field count.
PR-URL: https://github.com/nodejs/node/pull/36991
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
2021-01-20 01:27:41 +01:00
Caleb ツ Everett
fef21282ef
build: fix compiling against openssl with no-psk
...
Node 15 prior to this commit will not compile if openssl is built with
no-psk. Compiling emits an error like this:
```
crypto_tls.cc:(.text+0x4c27): undefined reference to
`node::crypto::TLSWrap::SetCACerts(node::crypto::SecureContext*)'
```
Blame on crypto_tls.cc shows the file was created in a refactor. Before
that refactor SetCACerts was defined outside OPENSSL_NO_PSK ifndef.
PR-URL: https://github.com/nodejs/node/pull/36881
Fixes: https://github.com/nodejs/node/issues/36464
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Richard Lau <rlau@redhat.com >
2021-01-19 00:59:42 +01:00
raisinten
4ae31351ea
src: replace push_back with emplace_back in debug_utils
...
This prevents potential temporary object constructions.
PR-URL: https://github.com/nodejs/node/pull/36897
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2021-01-19 00:30:22 +01:00
Joyee Cheung
3ede3c2da9
src: use BaseObject::kInternalFieldCount in X509Certificate constructor
...
Use defined constant instead of hard-coding the field count
PR-URL: https://github.com/nodejs/node/pull/36892
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-18 14:02:06 -08:00
James M Snell
d4bea09a0a
buffer: introduce Blob
...
The `Blob` object is an immutable data buffer. This is a first step
towards alignment with the `Blob` Web API.
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/36811
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2021-01-18 13:55:25 -08:00
Yash Ladha
cb2535ef7f
os: performance improvement in vector allocation
...
We were using the result vector with an object which is not a primitive
data type, and going with the constructor allocation pattern it creates
a size of that vector and also initializes the spaces with the data type
as well which is in our case is `Local<Value>`. It leads to waste of
some CPU cycles and instead we just wanted to have some reserved space
in our vector.
We can use `reserve` method on vector to reserve some space for the
vector but doesn't initialize the value since we are anyways doing it in
the following loop.
PR-URL: https://github.com/nodejs/node/pull/36748
Reviewed-By: Robert Nagy <ronagy@icloud.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-18 13:41:29 -08:00
James M Snell
bd899bc656
crypto: experimental (Ed/X)25519/(Ed/X)448 support
...
Implements initial experimental support for Curve25519 and
Curve448 support for both ECDH and sign/verify in Web Crypto.
Introduced as a Node.js-specific extension to Web Crypto.
Signed-off-by: James M Snell <jasnell@gmail.com >
Fixes: https://github.com/nodejs/node/issues/36076
PR-URL: https://github.com/nodejs/node/pull/36879
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
2021-01-18 08:12:08 -08:00
Filip Skokan
f8ab632d56
buffer: add base64url encoding option
...
PR-URL: https://github.com/nodejs/node/pull/36952
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2021-01-18 12:08:20 +01:00
Tobias Nießen
6a7eb32c5b
crypto: fix WebCrypto import of RSA-PSS keys
...
This patch changes GetRsaKeyDetail to work in older supported versions
of OpenSSL.
Refs: https://github.com/openssl/openssl/pull/10217
PR-URL: https://github.com/nodejs/node/pull/36877
Refs: https://github.com/nodejs/node/pull/36188
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: Richard Lau <rlau@redhat.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2021-01-13 15:34:06 +01:00
raisinten
72b678a0b3
fs: allow position parameter to be a BigInt in read and readSync
...
Fixes: https://github.com/nodejs/node/issues/36185
PR-URL: https://github.com/nodejs/node/pull/36190
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2021-01-13 15:19:50 +01:00
James M Snell
03c056401f
crypto: implement basic secure heap support
...
Adds two new command line arguments:
* `--secure-heap=n`, which causes node.js to initialize
an openssl secure heap of `n` bytes on openssl initialization.
* `--secure-heap-min=n`, which specifies the minimum allocation
from the secure heap.
* A new method `crypto.secureHeapUsed()` that returns details
about the total and used secure heap allocation.
The secure heap is an openssl feature that allows certain kinds
of potentially sensitive information (such as private key
BigNums) to be allocated from a dedicated memory area that is
protected against pointer over- and underruns.
The secure heap is a fixed size, so it's important that users
pick a large enough size to cover the crypto operations they
intend to utilize.
The secure heap is disabled by default.
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/36779
Refs: https://github.com/nodejs/node/pull/36729
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
2021-01-11 10:39:00 -08:00
Ikko Ashimine
a3606f25dc
src: fix typo in crypto_aes.cc
...
concatentated -> concatenated
PR-URL: https://github.com/nodejs/node/pull/36717
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Pooja D P <Pooja.D.P@ibm.com >
Reviewed-By: Michael Dawson <midawson@redhat.com >
Reviewed-By: Richard Lau <rlau@redhat.com >
2021-01-10 06:58:42 +05:30
James M Snell
f5287a4b7b
crypto: introduce X509Certificate API
...
Introduces the `crypto.X509Certificate` object.
```js
const { X509Certificate } = require('crypto');
const x509 = new X509Certificate('{pem encoded cert}');
console.log(x509.subject);
```
Fixes: https://github.com/nodejs/node/issues/29181
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/36804
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
2021-01-09 12:04:23 -08:00
James M Snell
0008a675ff
crypto: implement randomuuid
...
Signed-off-by: James M Snell <jasnell@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/36729
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: Ben Coe <bencoe@gmail.com >
2021-01-07 12:44:36 -08:00
James M Snell
b0ac080fa7
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
Refs: https://hackerone.com/bugs?subject=nodejs&report_id=988103
PR-URL: https://github.com/nodejs-private/node-private/pull/23
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-01-04 17:10:40 +00:00
Thiago Padilha
25b21e478e
child_process: add 'overlapped' stdio flag
...
The 'overlapped' value sets the UV_OVERLAPPED_PIPE libuv flag in the
child process stdio.
Fixes: https://github.com/nodejs/node/issues/29238
PR-URL: https://github.com/nodejs/node/pull/29412
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-03 22:40:50 +01: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
Adrien Maret
83ab5433ff
process: add direct access to rss without iterating pages
...
Accessing the rss value through memoryUsage() can be expensive
because this method will also generate memory usage statistics
by iterating on each page.
This commit intend to offer a more direct access to rss value.
Refs: #33384
PR-URL: https://github.com/nodejs/node/pull/34291
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-03 13:16:36 +00:00
raisinten
b8c15c7413
src: fix leading backslash bug in URL
...
The associated condition mentioned in the URL parsing algorithm of the
WHATWG URL Standard is:
url is special and c is U+005C (\)
So, `special_back_slash` must be updated whenever `special` is updated.
Fixes: https://github.com/nodejs/node/issues/36559
PR-URL: https://github.com/nodejs/node/pull/36613
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-12-31 12:31:03 -08:00
Michaël Zasso
11b34a916f
string_decoder: throw ERR_STRING_TOO_LONG for UTF-8
...
String::NewFromUtf8 doesn't generate an exception in V8 when the string
is too long but is guaranteed to return an empty MaybeLocal only in
that case. Generate a Node.js exception when it happens.
Fixes: https://github.com/nodejs/node/issues/35676
PR-URL: https://github.com/nodejs/node/pull/36661
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-12-31 15:40:01 +00:00
raisinten
c380ee6785
fs: accept non-32-bit length in writeBuffer
...
Since `length` is `size_t`, it can accept 64-bit integers too.
Refs: https://man7.org/linux/man-pages/man2/write.2.html
Fixes: https://github.com/nodejs/node/issues/36643
PR-URL: https://github.com/nodejs/node/pull/36667
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Yash Ladha <yash@yashladha.in >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
2020-12-30 16:56:18 +00:00
ExE Boss
d90fa196c5
v8: fix native serdes constructors
...
Fixes: https://github.com/nodejs/node/issues/13326
Refs: https://github.com/nodejs/node/pull/13541
PR-URL: https://github.com/nodejs/node/pull/36549
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2020-12-22 14:13:56 +01:00
Daniel Bevenius
fc8fcb084d
src: remove unnecessary ToLocalChecked node_errors
...
PR-URL: https://github.com/nodejs/node/pull/36547
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-22 09:28:23 +01:00
Anna Henningsen
2070d5b524
src: use correct microtask queue for checkpoints
...
I missed in c6c8337402 that we should not just use that queue for
enqueuing microtasks, but also for running them.
Refs: https://github.com/nodejs/node/pull/36482
PR-URL: https://github.com/nodejs/node/pull/36581
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
2020-12-21 13:28:51 +01:00
Daniel Bevenius
eb14b10370
src: remove unnecessary ToLocalChecked call
...
PR-URL: https://github.com/nodejs/node/pull/36523
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Richard Lau <rlau@redhat.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2020-12-17 05:06:57 +01:00
raisinten
5a637e9d36
src: remove empty name check in node_env_var.cc
...
The empty name check has been removed since this has landed:
https://github.com/libuv/libuv/pull/2473
PR-URL: https://github.com/nodejs/node/pull/36133
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-12-15 15:53:37 +00:00
Anna Henningsen
67643e1c2e
worker: fix broadcast channel SharedArrayBuffer passing
...
Make sure that `SharedArrayBuffer`s can be deserialized on multiple
receiving ends. As a drive-by, also fix the condition of the
internal assertion that should occur if there are transferables
passed to multiple destinations.
PR-URL: https://github.com/nodejs/node/pull/36501
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-12-14 16:50:23 +01:00
Daniel Bevenius
903998aced
src: remove duplicate V macros in node_v8.cc
...
PR-URL: https://github.com/nodejs/node/pull/36454
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-14 08:01:13 +01:00
Anna Henningsen
c6c8337402
src: use correct outer Context’s microtask queue
...
Fall back to using the outer context’s microtask queue, rather than
the Isolate’s default one. This would otherwise result in surprising
behavior if an embedder specified a custom microtask queue for the
main Node.js context.
PR-URL: https://github.com/nodejs/node/pull/36482
Refs: https://github.com/v8/v8/commit/4bf051d536a172e7932845d82f918ad7280c7873
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-13 22:03:45 +01:00
Anna Henningsen
d313bf7d47
src: add way to get IsolateData and allocator from Environment
...
Add a way to get the current `IsolateData*` and, from it, the current
Node.js `ArrayBufferAllocator` if there is one. This can be useful
for re-using either one of these structures as an embedder.
PR-URL: https://github.com/nodejs/node/pull/36441
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com >
Reviewed-By: Richard Lau <rlau@redhat.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-13 15:03:19 +00:00
Anna Henningsen
7069d22343
src: guard against env != null in node_errors.cc
...
Otherwise
`TriggerUncaughtException()`
→ `PrintException()`
→ `GetErrorSource()`
can crash.
PR-URL: https://github.com/nodejs/node/pull/36414
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.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: Shelley Vohr <codebytere@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-13 14:28:21 +00:00
Anna Henningsen
88dfecc44b
worker: refactor MessagePort entanglement management
...
This addresses the `TODO` left on my request in 9e446b3e9 . :)
Refs: https://github.com/nodejs/node/pull/36271
PR-URL: https://github.com/nodejs/node/pull/36345
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-13 14:28:12 +00:00
Shelley Vohr
743ee9d2c0
src: allow preventing SetPrepareStackTraceCallback
...
Node.js sets a stack trace handler specific to the v8::Context
corresponding to the current Environment. When Electron is running in a
non-Node.js v8::Context (e.g in the renderer process with
contextIsolation enabled), there will be no correspondent Environment -
we therefore need to prevent this handler being set so that Blink falls
back to its default handling and displays the correct stacktrace.
PR-URL: https://github.com/nodejs/node/pull/36447
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-11 15:05:17 -08:00
Nicolai Stange and ZauberNerd
c53ba1f618
perf_hooks: invoke performance_entry_callback via MakeSyncCallback()
...
It's desirable to retain async_contexts active at callsites of
perf_hooks.performance.mark() and alike in the subsequent
PerformanceObserver invocations such that the latter can access e.g.
associated AsyncLocalStorage instances.
In working towards this goal replace the node::MakeCallback(...,
async_context{0, 0}) in PerformanceEntry::doNotify() by the new
node::MakeSyncCallback() introduced specifically for this purpose.
This change will retain the original async_context, if any, in
perf_hook's observersCallback() and thus, for the subsequent doNotify()
on unbuffered PerformanceObservers.
Co-Authored-By: ZauberNerd <zaubernerd@zaubernerd.de >
PR-URL: https://github.com/nodejs/node/pull/36343
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-11 04:45:16 -08:00
Nicolai Stange and ZauberNerd
348a3adacb
src: introduce convenience node::MakeSyncCallback()
...
There are situations where one wants to invoke a JS callback's ->Call()
from C++ and in particular retain any existing async_context state, but
where it's not obvious that a plain ->Call() would be safe at the point
in question.
Such callsites usually resort to
node::MakeCallback(..., async_context{0, 0}), which unconditionally
pushes the async_context{0, 0} and takes the required provisions for the
->Call() itself such as triggering the tick after its return, if needed.
An example would be the PerformanceObserver invocation from
PerformanceEntry::Notify(): this can get called when coming from JS
through e.g. perf_hooks.performance.mark() and alike, but perhaps also
from nghttp2 (c.f. EmitStatistics() in node_http2.cc).
In the former case, a plain ->Call() would be safe and it would be
desirable to retain the current async_context so that
PerformanceObservers can access it resp. the associated
AsyncLocalStorage. However, in the second case the additional provisions
taken by node::MakeCallback() might potentially be strictly required.
So PerformanceEntry::Notify() bites the bullet and invokes the
PerformanceObservers through node::MakeCallback() unconditionally,
thereby always rendering any possibly preexisting async_context
inaccessible.
Introduce the convenience node::MakeSyncCallback() for such usecases,
which would basically forward to ->Call() if safe and to
node::MakeCallback(..., async_context{0, 0}) otherwise.
Co-Authored-By: ZauberNerd <zaubernerd@zaubernerd.de >
PR-URL: https://github.com/nodejs/node/pull/36343
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-11 04:43:27 -08:00
Daniel Bevenius
f49cef549c
src: add typedef for CleanupHookCallback callback
...
This commit adds a typedef for the callback parameter used in
CleanupHookCallback's constructor, AddCleanupHook, and
RemoveCleanupHook.
PR-URL: https://github.com/nodejs/node/pull/36442
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-11 07:31:41 +01:00
Richard Lau
87dc152229
src: fix node version
...
PR-URL: https://github.com/nodejs/node/pull/36460
Refs: https://github.com/nodejs/node/commit/348b7a9606da61fbb5437e27f479363114ecf4eb#r44957158
Refs: https://github.com/nodejs/node/pull/36385
Reviewed-By: Beth Griggs <bgriggs@redhat.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
Reviewed-By: Danielle Adams <adamzdanielle@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michael Dawson <midawson@redhat.com >
2020-12-09 23:49:14 +00:00