So it's easier to tell the side effects of this setup.
PR-URL: https://github.com/nodejs/node/pull/25443
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Many Inspector protocol clients rely on the top frame reported for the
console messages. This test makes sure correct location is reported.
PR-URL: https://github.com/nodejs/node/pull/25455
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
- Renamed `internal/process/write-coverage.js` to
`internal/coverage-gen/with_instrumentation.js`,
`internal/process/coverage.js` to
`internal/coverage-gen/with_profiler.js` to distinguish
the two better and added comments.
- Separate the coverage directory setup and the connection
setup, moves the directory setup into `node.js` and
closer to the exit hooks because that's where it's used.
- Moves the `process.reallyExit` overwrite and
`process.on('exit')` hooks setup into bootstrap/node.js
for clarity, and move them to a later stage of
bootstrap since they do not have to happen that early.
PR-URL: https://github.com/nodejs/node/pull/25398
Reviewed-By: Ben Coe <bencoe@gmail.com>
For an unsupported OS, a call to os.cpus() throws an error
within os.cpus() itself where it tries to get the length of it.
This fixes the issue by adding fallback for undefined CPUs.
Fixes: https://github.com/nodejs/node/issues/25483
PR-URL: https://github.com/nodejs/node/pull/25493
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: https://github.com/nodejs/node/pull/25481
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
The idea is to allow the C++ layer to run arbitrary scripts
as the main script. This paves the way for
- cctest of the execution of Node.js instances
- Earlier handling of per-process CLI options that affect
execution modes (those usually do not make sense for the
embedders).
- Targets like mkcodecache or mksnapshot.
Also moves the handling of `_third_party_main.js` into C++.
PR-URL: https://github.com/nodejs/node/pull/25474
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Improve known_issues/test-vm-timeout-escape-queuemicrotask to mitigate
CI failures on ubuntu1604-arm64. Failures are due to a race condition.
Use `common.platformTimeout()` to help, adjust timeout to make sure
`queueMicrotasks()` has a chance to run, and improve error message.
PR-URL: https://github.com/nodejs/node/pull/25503
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Coe <bencoe@gmail.com>
The API has existed forever and is used in our unit tests. It is
supported for TLS1.3 as well as 1.2 and useful for troubleshooting, so
it should be documented.
PR-URL: https://github.com/nodejs/node/pull/25423
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- Use complete examples that can be pasted and run as-is
- Move note about algorithm to the functions it applies to
- Uncapitalize inconsistence use of "Class"
- Use both EC and RSA keys in the examples
- Note that hash and digest are two names for the same algorithms
PR-URL: https://github.com/nodejs/node/pull/25452
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/25439
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Move `node::errno_string` into node_errors.h/cc and move it into
the `node:errors` namespace to reduce the size of the header.
It's not on any performance-critical code path so does not need
to be inlined.
PR-URL: https://github.com/nodejs/node/pull/25396
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
PR-URL: https://github.com/nodejs/node/pull/25394
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yang Guo <yangguo@chromium.org>
This PR just places the `vm.SourceTextModule` class section
after the `vm.Script` class section, restoring the alphabetical order.
PR-URL: https://github.com/nodejs/node/pull/25374
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Remove:
- use of tls global so tests can run in parallel
- test counting in favour of common.mustCall()
- limit of only one cipher suite per ephemeral key type tested
The last change will allow adding TLS 1.3 cipher suites and testing
'ECDH' key info with them.
PR-URL: https://github.com/nodejs/node/pull/25409
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Check that the return value and callback error for tls.renegotiate()
does not indicate a failure. Also, remove unnecessary line wrapping and
indentation.
PR-URL: https://github.com/nodejs/node/pull/25437
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
test-net-connect-econnrefused was recently fixed, but only in certain
circumstances. This change allows it to succeed whether it is invoked
with `node` or `tools/test.py`. Makes sure no Socket handles are left,
which is what the test is trying to determine, rather than failing if
there are no handles of any kind left.
PR-URL: https://github.com/nodejs/node/pull/25438
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Calling `process.exit()` calls the C `exit()` function, which in turn
calls the destructors of static C++ objects. This can lead to race
conditions with other concurrently executing threads; disposing of all
Worker threads and then the V8 platform instance helps with this
(although it might not be a full solution for all problems of
this kind).
Refs: https://github.com/nodejs/node/issues/24403
Refs: https://github.com/nodejs/node/issues/25007
PR-URL: https://github.com/nodejs/node/pull/25061
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
- Remove `NativeModule._source` - the compilation is now entirely
done in C++ and `process.binding('natives')` is implemented
directly in the binding loader so there is no need to store
additional source code strings.
- Instead of using an object as `NativeModule._cached` and insert
into it after compilation of each native module, simply prebuild
a JS map filled with all the native modules and infer the
state of compilation through `mod.loading`/`mod.loaded`.
- Rename `NativeModule.nonInternalExists` to
`NativeModule.canBeRequiredByUsers` and precompute that
property for all the native modules during bootstrap instead
of branching in every require call during runtime. This also fixes
the bug where `worker_threads` can be made available with
`--expose-internals`.
- Rename `NativeModule.requireForDeps` to
`NativeModule.requireWithFallbackInDeps`.
- Add a test to make sure we do not accidentally leak any module
to the global namespace.
PR-URL: https://github.com/nodejs/node/pull/25352
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Now that `worker_threads` do not require a flag, the logic around
loading `isMainThread` can be removed.
PR-URL: https://github.com/nodejs/node/pull/25426
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Use of process.binding() has largely been replaced by
internalBinding(). This commit updates the custom crypto
check ESLint rule to check for both process.binding() and
internalBinding().
Refs: https://github.com/nodejs/node/pull/24952
PR-URL: https://github.com/nodejs/node/pull/25395
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
`vm` module API heavily reuses common code, but the doc seems
to be a bit out of date: some options are listed in wrong places,
some options and history entries are missed.
Also some fragments need to be formalized and unified.
PR-URL: https://github.com/nodejs/node/pull/25422
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Rewrite worker_threads introductory material focusing on simpler and
shorter sentences.
PR-URL: https://github.com/nodejs/node/pull/25402
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* alphabetize require() statements for built-in modules by module name
* remove unused function argument `code` in callback
* replace common.expectsError() with assert.throws()
* remove unneeded line-wrap
PR-URL: https://github.com/nodejs/node/pull/25401
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
AIX 7.1 appears to return a different error message compared to AIX 6.1.
PR-URL: https://github.com/nodejs/node/pull/25418
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: George Adams <george.adams@uk.ibm.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
PR-URL: https://github.com/nodejs/node/pull/25400
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Move the C++ `process.emit` and `process.emitWarning` methods
from `node.cc` into into `node_process_events.cc`, and
reuse the implementation in other places that need to do
`process.emit` in C++.
PR-URL: https://github.com/nodejs/node/pull/25397
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Instead of in node_internals.h. Also move process property
accessors that are not reused into node_process_object.cc
and make them static.
PR-URL: https://github.com/nodejs/node/pull/25397
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Changes `SetupProcessObject` to `CreateProessObject` which creates
the process object from scratch and return it to `Environment::Start`
to be stored in the Environment object.
PR-URL: https://github.com/nodejs/node/pull/25397
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit updates the custom crypto-check ESLint rule to
detect require() calls that come before any hasCrypto
checks.
PR-URL: https://github.com/nodejs/node/pull/25399
Refs: https://github.com/nodejs/node/pull/25388
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
This removes a special casing for this data type in the main function.
PR-URL: https://github.com/nodejs/node/pull/25255
Reviewed-By: James M Snell <jasnell@gmail.com>
Remove some dead code plus some minor refactoring for readability.
The constructor can not be an empty string anymore, so just remove
that check.
PR-URL: https://github.com/nodejs/node/pull/25255
Reviewed-By: James M Snell <jasnell@gmail.com>
This makes sure the counter goes up instead of going down. This allows
to properly track the current inspection depth no matter what the
`depth` option was set to.
PR-URL: https://github.com/nodejs/node/pull/25255
Reviewed-By: James M Snell <jasnell@gmail.com>
This makes the STL variant of `node::Init()` a bit more
suitable for inclusion in a proper embedder API, as errors
or other output are reported to the caller rather than
directly being printed, and the process is not exited
directly either.
PR-URL: https://github.com/nodejs/node/pull/25370
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Currently, when specifying the --openssl-fips flag without any path
, or an empty path, does not generate an error. If a path is specified
then the following error is generated:
ERROR: FIPS is not supported in this version of Node.js
This commit adds a check so that the error is generated even if the
path is empty.
PR-URL: https://github.com/nodejs/node/pull/25391
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Currently, test-https-client-override-global-agent.js fails with the
following error when configured --without-ssl:
Error [ERR_NO_CRYPTO]:
Node.js is not compiled with OpenSSL crypto support
at Object.assertCrypto (internal/util.js:101:11)
...
at Object.<anonymous>
(/node/test/parallel/test-https-client-override-global-agent.js:5:15)
This commit moves the require statement to after the crypto check.
PR-URL: https://github.com/nodejs/node/pull/25388
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>