All calls verify the cb is called, thus using `common.mustCall` is
not required inside of this function.
PR-URL: https://github.com/nodejs/node/pull/26738
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This adds a custom eslint rule to verify that
`Error.captureStackTrace()` is only called if necessary. In most
cases the helper function should be used instead.
PR-URL: https://github.com/nodejs/node/pull/26738
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
When using `Errors.captureStackFrames` the error's stack property
is set again. This adds a helper function that wraps this functionality
in a simple API that does not only set the stack including the `code`
property but it also improves the performance to create the error.
The helper works for thrown errors and errors returned from wrapped
functions in case they are Node.js core errors.
PR-URL: https://github.com/nodejs/node/pull/26738
Fixes: https://github.com/nodejs/node/issues/26669
Fixes: https://github.com/nodejs/node/issues/20253
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This updates all Node.js errors by removing the `code` being part
of the `name` property. Instead, the name is just changed once on
instantiation, the stack is accessed to create the stack as expected
and then the `name` property is set back to it's original form.
PR-URL: https://github.com/nodejs/node/pull/26738
Fixes: https://github.com/nodejs/node/issues/26669
Fixes: https://github.com/nodejs/node/issues/20253
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/26813
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
PR-URL: https://github.com/nodejs/node/pull/26812
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Move test-tls-session-timeout from pummel to sequential. It isn't very
pummel-y and this will result in it being run on our CI more than once a
day. (It broke recently and it would have been caught if it was in
sequential rather than pummel.)
It must be in sequential rather than pummel because it uses
`common.PORT` which can result in test failures if more than one test
uses it at one time in parallel.
PR-URL: https://github.com/nodejs/node/pull/26865
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
The test does not work with TLS 1.3 nor should it. Force TLS version
1.2.
While at it, some refactoring:
* refresh the tmp directory in case it doesn't exist!
* add an assert.strictEqual() check on the client return `code` value
which must be zero
* use arrow functions for callbacks
* add trailing commas for multiline arrays/objects
Fixes: https://github.com/nodejs/node/issues/26839
PR-URL: https://github.com/nodejs/node/pull/26865
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
There is one condition in the `console.assert()` code that is not
tested currently. Add a test to confirm that `console.assert(false)`
does not include a `:` in its output.
PR-URL: https://github.com/nodejs/node/pull/26827
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Coverity was complaining that this field was not initialized.
PR-URL: https://github.com/nodejs/node/pull/26739
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
test-console-stdio-setters needs to test against the global console in
order to test the setters for the lazy-loaded _stdout and _stderr
properties.
PR-URL: https://github.com/nodejs/node/pull/26796
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Restore running tests on Travis once the ccache is populated.
PR-URL: https://github.com/nodejs/node/pull/26720
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
We're hitting the Travis job timeout of 50mins if built with a new
compiler (as there is no ccache). Temporarily disable the running
of tests so the Travis job can complete within the timeout and
populate the ccache.
PR-URL: https://github.com/nodejs/node/pull/26720
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
When old and new size match, we can skip the rest of the function,
which makes sense in the case of embedders who do not use Node's
allocator, as that would lead to needlessly allocating and freeing
buffers of identical sizes.
PR-URL: https://github.com/nodejs/node/pull/26573
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
This fixes issues in which APIs that accept pointers created this way
treat `nullptr` and a zero-length buffer differently.
We already do something similar for our `Malloc()` implementation.
PR-URL: https://github.com/nodejs/node/pull/26731
Fixes: https://github.com/nodejs/node/issues/26514
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: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/26734
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
- Follow style guide for naming, e.g. use lower_snake_case
for simple setters/getters.
- For performance, use atomics instead of a mutex, and inline
the corresponding getter/setter pair.
PR-URL: https://github.com/nodejs/node/pull/26757
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Since `internal/errors` is loaded by many builtin modules and is
currently the first module loaded during bootstrap, it is
fine to load it eagerly. We just need to make sure
that `internal/errors` itself load other modules lazily.
PR-URL: https://github.com/nodejs/node/pull/26771
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Since `internal/errors` is loaded by many builtin modules and is
currently the first module loaded during bootstrap, it is
fine to load it eagerly. We just need to make sure
that `internal/errors` itself load other modules lazily.
PR-URL: https://github.com/nodejs/node/pull/26771
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
When TERM=dumb and .isTTY=true don't use ANSI escape codes
and ignore all keys, except 'escape', 'return' and 'ctrl-c'.
PR-URL: https://github.com/nodejs/node/pull/26261
Fixes: https://github.com/nodejs/node/issues/26187
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This validates most `assert` functions to verify that the required
arguments are indeed passed to the function.
PR-URL: https://github.com/nodejs/node/pull/26641
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
A recent refactoring made the slight mistake of calling `trace()`
instead of `this.trace()`.
PR-URL: https://github.com/nodejs/node/pull/26764
Fixes: https://github.com/nodejs/node/issues/26763
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
This encapsulates the Node.js errors more by adding extra properties
to an error inside of the function to create the error message instead
of adding the properties at the call site. That simplifies the usage
of our errors and makes sure the expected properties are always set.
PR-URL: https://github.com/nodejs/node/pull/26752
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
These tests tested internal functionality in a way that bypassed all
code that could reach these cases. It gives a false feeling of safety
that some code works as intended while there is no guarantee that
it indeed works as it should.
Therefore it seemed best to remove all of these. The only thing that
should be tested is the raw functionality of the internal errors.
PR-URL: https://github.com/nodejs/node/pull/26752
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Disallow constructor behaviour and setting up prototypes
for native methods that are not constructors (i.e. make
them behave like ES6 class methods).
PR-URL: https://github.com/nodejs/node/pull/26700
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/26585
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Use the variant of GC callbacks that takes data to
avoid running into DCHECKs when multiple Environments try to add
the same callback to the same isolate multiple times.
In addition, remove the callbacks in the Environment cleanup hook.
PR-URL: https://github.com/nodejs/node/pull/26742
Fixes: https://github.com/nodejs/node/issues/26736
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/26729
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Optimize test-http2-large-file so it only allocates a single buffer.
PR-URL: https://github.com/nodejs/node/pull/26737
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Adrian Estrada <edsadr@gmail.com>