Change the `MyError` example so that instances of `MyError`are
`instanceof Error` and also native errors when checked with
`util.types.isNativeError()`.
Co-authored-by: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: https://github.com/nodejs/node/pull/46886
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Citing 76b0bdf720 from 2012, "only use
this as a temporary measure."
Getting or setting DEFAULT_ENCODING has emitted a warning ever since
Node.js 10, so it seems appropriate to remove it in Node.js 20 five
years later. The last Node.js version that did not emit a warning
reached its end-of-life status at the end of 2019.
This commit only removes the public API so that the change can land in
time for Node.js 20.
Refs: https://github.com/nodejs/node-v0.x-archive/pull/4179
Refs: https://github.com/nodejs/node/pull/18333
PR-URL: https://github.com/nodejs/node/pull/47182
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Beth Griggs <bethanyngriggs@gmail.com>
Reviewed-By: Erick Wendel <erick.workspace@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
signtool still defaults to SHA1, which is vulnerable to certain
collisions. This switches to SHA256, which is stronger and which also
matches the hash function used by the signing certificate.
Technically, `/fd certHash` would be a better choice, but I don't know
if it is widely supported.
PR-URL: https://github.com/nodejs/node/pull/47206
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Refs: https://github.com/nodejs/TSC/issues/1340
PR-URL: https://github.com/nodejs/node/pull/47211
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Original commit message:
Use FlagValue::value() in SLOW_DCHECK
Previously SLOW_DCHECK used the non-constexpr bool() operator
of FlagValue, which cannot be used in constexpr. Switch to
FlagValue::value() instead for make it compile in constexpr.
Change-Id: I3e4f70d82c0027cf56999b6c4639479606151696
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4341495
Reviewed-by: Jakob Linke <jgruber@chromium.org>
Commit-Queue: Joyee Cheung <joyee@igalia.com>
Cr-Commit-Position: refs/heads/main@{#86611}
Refs: 215ccd593e
PR-URL: https://github.com/nodejs/node/pull/47212
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
This is required for streams interop with e.g.
readable-stream. Currently readable-stream helpers
will not work with normal node streams which is
confusing and bad for the ecosystem.
PR-URL: https://github.com/nodejs/node/pull/45671
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Re-output failing tests after summary has been printed.
This behavior follows other popular test runners
(e.g. jest, mocha, etc...).
Updated SpecReporter:
1. When there is a 'test:fail' event, the test will be
stored.
2. After no more input, all the failed tests will be
flushed.
3. Extract the logic for formatting a test report
into a re-usable function.
Fixes: https://github.com/nodejs/node/issues/47110
PR-URL: https://github.com/nodejs/node/pull/47164
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
There is no point in documenting this legacy behavior, which will emit a
warning when used.
PR-URL: https://github.com/nodejs/node/pull/47181
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
The JS layer already verifies that divisor_bits is either a non-negative
32-bit signed integer or null/undefined, in which case it passes -1 to
the C++ layer. In either case, the C++ layer receives a 32-bit signed
integer greater than or equal to -1.
PR-URL: https://github.com/nodejs/node/pull/47168
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Previously, the JS layer would validate that the value of the 'checks'
option was an unsigned 32-bit integer, otherwise throwing an appropriate
error but with a slightly misleading error message. Then the C++ layer
would validate that the value was an unsigned 31-bit integer, otherwise
throwing an appropriate error, but with a different (and even less
helpful) error message.
Instead, make the JS layer aware of the 31-bit restriction so that no
validation in C++ is necessary and so that the error message always
matches the exact requirement.
PR-URL: https://github.com/nodejs/node/pull/47165
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Logs the raw messages from the inspector when NODE_DEBUG_NATIVE
is set to inspector_server to facilitate debugging.
PR-URL: https://github.com/nodejs/node/pull/46941
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Since externals behave as JavaScript objects on the JavaScript side,
allow them to be type-tagged.
Signed-off-by: Gabriel Schulhof <gabrielschulhof@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/47141
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/47175
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Christian Clauss <cclauss@me.com>
None of these constants have any effect in recent OpenSSL versions, not
even in Node.js release lines that still use OpenSSL 1.1.1.
It is likely rare that these options are still used (intentionally), and
removing them is unlikely to break any existing applications. These
constants can only be passed to the secureOptions option of
tls.createSecureContext() and related APIs, and a value of undefined
will be ignored. Similarly, if a bitwise combination of multiple options
is used, undefined constants will not change the behavior because
(a | undefined | b) === (a | b) for (small) integers a and b.
Refs: https://github.com/nodejs/node/pull/46954
Refs: https://github.com/nodejs/node/pull/47066
PR-URL: https://github.com/nodejs/node/pull/47073
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
As status quo, the cleanup hooks are invoked before the `napi_finalize`
callbacks at the exit of Node.js environments. This gives addons a
chance to release their resource in a proper order manually.
Document this behavior explicitly to advocate the usage on cleanup
hooks instead of relying on the implied invocation of `napi_finalize`
callbacks at shutdown.
PR-URL: https://github.com/nodejs/node/pull/45903
Fixes: https://github.com/nodejs/node/issues/45088
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
This test had two problems:
* The first argument was a number in both cases, which is what caused
the (expected) ERR_INVALID_ARG_TYPE error -- the validity of the
'checks' option was not actually verified at all. Thus, the first
argument should be valid for this particular test.
* The function returned by common.mustNotCall() was passed to
assert.throws() as a third argument instead of being passed to
checkPrime() as a third argument. (Isn't JavaScript great?) This again
led to the (expected) ERR_INVALID_ARG_TYPE error, but again, the
validity of the 'checks' option was not verified.
Fix both issues by ensuring that all arguments except the 'checks'
option are valid.
Refs: https://github.com/nodejs/node/pull/36997
PR-URL: https://github.com/nodejs/node/pull/47139
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>