Update Node.js to v22 #356
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "renovate/node-22.x"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR contains the following updates:
16.20.2-bullseye-slim
->22.9.0-bullseye-slim
Release Notes
nodejs/node (node)
v22.9.0
: 2024-09-17, Version 22.9.0 (Current), @RafaelGSSCompare Source
New API to retrieve execution Stack Trace
A new API
getCallSite
has been introduced to theutil
module. This API allows usersto retrieve the stacktrace of the current execution. Example:
Thanks to Rafael Gonzaga for making this work on #54380.
Disable V8 Maglev
We have seen several crashes/unexpected JS behaviors with maglev on v22
(which ships V8 v12.4). The bugs lie in the codegen so it would be difficult for
users to work around them or even figure out where the bugs are coming from.
Some bugs are fixed in the upstream while some others probably remain.
As v22 will get stuck with V8 v12.4 as LTS, it will be increasingly difficult to
backport patches for them even if the bugs are fixed. So disable it by default
on v22 to reduce the churn and troubles for users.
Thanks to Joyee Cheung for making this work on #54384
Exposes X509_V_FLAG_PARTIAL_CHAIN to tls.createSecureContext
This releases introduces a new option to the API
tls.createSecureContext
. Fornow on users can use
tls.createSecureContext({ allowPartialTrustChain: true })
to treat intermediate (non-self-signed) certificates in the trust CA certificate
list as trusted.
Thanks to Anna Henningsen for making this work on #54790
Other Notable Changes
Deprecations
Commits
v22.8.0
: 2024-09-03, Version 22.8.0 (Current), @RafaelGSSCompare Source
New JS API for compile cache
This release adds a new API
module.enableCompileCache()
that can be used to enable on-disk code caching of all modules loaded after this API is called.Previously this could only be enabled by the
NODE_COMPILE_CACHE
environment variable, so it could only set by end-users.This API allows tooling and library authors to enable caching of their own code.
This is a built-in alternative to the v8-compile-cache/v8-compile-cache-lib packages,
but have better performance and supports ESM.
Thanks to Joyee Cheung for working on this.
New option for vm.createContext() to create a context with a freezable globalThis
Node.js implements a flavor of
vm.createContext()
and friends that creates a context without contextifying its globalobject when vm.constants.DONT_CONTEXTIFY is used. This is suitable when users want to freeze the context
(impossible when the global is contextified i.e. has interceptors installed) or speed up the global access if they
don't need the interceptor behavior.
Thanks to Joyee Cheung for working on this.
Support for coverage thresholds
Node.js now supports requiring code coverage to meet a specific threshold before the process exits successfully.
To use this feature, you need to enable the
--experimental-test-coverage
flag.You can set thresholds for the following types of coverage:
--test-coverage-branches=<threshold>
--test-coverage-functions=<threshold>
--test-coverage-lines=<threshold>
<threshold>
should be an integer between 0 and 100. If an invalid value is provided, aTypeError
will be thrown.If the code coverage fails to meet the specified thresholds for any category, the process will exit with code
1
.For instance, to enforce a minimum of 80% line coverage and 60% branch coverage, you can run:
Thanks Aviv Keller for working on this.
Other Notable Changes
Commits
v22.7.0
: 2024-08-22, Version 22.7.0 (Current), @RafaelGSSCompare Source
Experimental transform types support
With the new flag
--experimental-transform-types
it is possible to enable thetransformation of TypeScript-only syntax into JavaScript code.
This feature allows Node.js to support TypeScript syntax such as
Enum
andnamespace
.Thanks to Marco Ippolito for making this work on #54283.
Module syntax detection is now enabled by default.
Module syntax detection (the
--experimental-detect-module
flag) is nowenabled by default. Use
--no-experimental-detect-module
to disable it ifneeded.
Syntax detection attempts to run ambiguous files as CommonJS, and if the module
fails to parse as CommonJS due to ES module syntax, Node.js tries again and runs
the file as an ES module.
Ambiguous files are those with a
.js
or no extension, where the nearest parentpackage.json
has no"type"
field (either"type": "module"
or"type": "commonjs"
).Syntax detection should have no performance impact on CommonJS modules, but it
incurs a slight performance penalty for ES modules; add
"type": "module"
tothe nearest parent
package.json
file to eliminate the performance cost.A use case unlocked by this feature is the ability to use ES module syntax in
extensionless scripts with no nearby
package.json
.Thanks to Geoffrey Booth for making this work on #53619.
Performance Improvements to Buffer
Performance of Node.js Buffers have been optimized through multiple PR's with significant
improvements to the
Buffer.copy
andBuffer.write
methods. These are used throughoutthe codebase and should give a nice boost across the board.
Thanks to Robert Nagy for making this work on #54311,
#54324, and #54087.
Other Notable Changes
Commits
v22.6.0
: 2024-08-06, Version 22.6.0 (Current), @RafaelGSSCompare Source
Experimental TypeScript support via strip types
Node.js introduces the
--experimental-strip-types
flag for initial TypeScript support.This feature strips type annotations from .ts files, allowing them to run
without transforming TypeScript-specific syntax. Current limitations include:
enums
ornamespaces
.Thanks Marco Ippolito for working on this.
Experimental Network Inspection Support in Node.js
This update introduces the initial support for network inspection in Node.js.
Currently, this is an experimental feature, so you need to enable it using the
--experimental-network-inspection
flag.With this feature enabled, you can inspect network activities occurring within a JavaScript application.
To use network inspection, start your Node.js application with the following command:
Please note that the network inspection capabilities are in active development.
We are actively working on enhancing this feature and will continue to expand its functionality in future updates.
http
andhttps
modules only.feature request on the Chrome DevTools side is addressed.
Thanks Kohei Ueno for working on this.
Other Notable Changes
Commits
v22.5.1
: 2024-07-19, Version 22.5.1 (Current), @richardlauCompare Source
Notable Changes
This release fixes a regression introduced in Node.js 22.5.0. The problem is known to display the following symptoms:
FATAL ERROR: v8::Object::GetCreationContextChecked No creation context available
#53902npm error Exit handler never called!
npm/cli#7657Usage Error: Couldn't find the node_modules state file - running an install might help (findPackageLocation)
yarnpkg/berry#6398Commits
v22.5.0
: 2024-07-17, Version 22.5.0 (Current), @RafaelGSS prepared by @aduh95Compare Source
Notable Changes
Commits
v22.4.1
: 2024-07-08, Version 22.4.1 (Current), @RafaelGSSCompare Source
This is a security release.
Notable Changes
Commits
v22.4.0
: 2024-07-02, Version 22.4.0 (Current), @targosCompare Source
Notable Changes
Experimental Web Storage API
API stability updates
Other Notable Changes
Commits
v22.3.0
: 2024-06-11, Version 22.3.0 (Current), @RafaelGSSCompare Source
Notable Changes
Commits
v22.2.0
: 2024-05-15, Version 22.2.0 (Current), @targosCompare Source
Notable Changes
Commits
v22.1.0
: 2024-05-02, Version 22.1.0 (Current), @targos prepared by @aduh95Compare Source
module: implement
NODE_COMPILE_CACHE
for automatic on-disk code cachingThis patch implements automatic on-disk code caching that can be enabled
via an environment variable
NODE_COMPILE_CACHE=/path/to/cache/dir
.When set, whenever Node.js compiles a CommonJS or a ECMAScript Module,
it will use on-disk V8 code cache
persisted in the specified directory
to speed up the compilation. This may slow down the first load of a
module graph, but subsequent loads of the same module graph may get
a significant speedup if the contents of the modules do not change.
Locally, this speeds up loading of
test/fixtures/snapshot/typescript.js
from ~130ms to ~80ms.
To clean up the generated code cache, simply remove the directory.
It will be recreated the next time the same directory is used for
NODE_COMPILE_CACHE
.Compilation cache generated by one version of Node.js may not be used
by a different version of Node.js. Cache generated by different versions
of Node.js will be stored separately if the same directory is used
to persist the cache, so they can co-exist.
Caveat: currently when using this with V8 JavaScript code coverage, the
coverage being collected by V8 may be less precise in functions that are
deserialized from the code cache. It's recommended to turn this off when
running tests to generate precise coverage.
Contributed by Joyee Cheung in #52535.
Other Notable Changes
Commits
v22.0.0
: 2024-04-24, Version 22.0.0 (Current), @RafaelGSS and @marco-ippolitoCompare Source
We're excited to announce the release of Node.js 22!
Highlights include require()ing ESM graphs, WebSocket client, updates of the V8 JavaScript engine, and more!
As a reminder, Node.js 22 will enter long-term support (LTS) in October, but until then, it will be the "Current" release for the next six months.
We encourage you to explore the new features and benefits offered by this latest release and evaluate their potential impact on your applications.
Other Notable Changes
Semver-Major Commits
Semver-Minor Commits
Semver-Patch Commits
v21.7.3
: 2024-04-10, Version 21.7.3 (Current), @RafaelGSSCompare Source
This is a security release.
Notable Changes
child_process.spawn
without shell option enabled on WindowsCommits
v21.7.2
: 2024-04-03, Version 21.7.2 (Current), @RafaelGSS prepared by @marco-ippolitoCompare Source
This is a security release.
Notable changes
Commits
v21.7.1
: 2024-03-08, Version 21.7.1 (Current), @targosCompare Source
Notable Changes
This release reverts #51389, which
landed in Node.js 21.7.0. It is a documented feature that
t.after()
hooks arerun even if a test has no subtests. The hook can be used to clean up the test
itself.
Commits
v21.7.0
: 2024-03-06, Version 21.7.0 (Current), @RafaelGSS prepared by @marco-ippolitoCompare Source
Text Styling
util.styleText(format, text)
: This function returns a formatted text considering theformat
passed.A new API has been created to format text based on
util.inspect.colors
, enabling you to style text in different colors (such as red, blue, ...) and emphasis (italic, bold, ...).Contributed by Rafael Gonzaga and Hemanth HM in #51850.
Loading and parsing environment variables
process.loadEnvFile(path)
:.env
file. If no path is specified, it automatically loads the .env file in the current directory. Example:process.loadEnvFile()
.process.loadEnvFile('./development.env')
.util.parseEnv(content)
:require('node:util').parseEnv('HELLO=world')
.Contributed by Yagiz Nizipli in #51476
Support for multi-line values for
.env
fileNode.js 21.7.0 will now support multi-line values in the .env file:
Contributed by Ilyas Shabi #51289
sea: support embedding assets
Users can now include assets by adding a key-path dictionary
to the configuration as the
assets
field. At build time, Node.jswould read the assets from the specified paths and bundle them into
the preparation blob. In the generated executable, users can retrieve
the assets using the
sea.getAsset()
andsea.getAssetAsBlob()
API.The single-executable application can access the assets as follows:
Contributed by Joyee Cheung in #50960
vm: support using the default loader to handle dynamic import()
This patch adds support for using
vm.constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
as theimportModuleDynamically
option in all vm APIs that take this option exceptvm.SourceTextModule
. This allows users to have a shortcut to support dynamicimport()
in the compiled code without missing the compilation cache if they don't need customization of the loading process. We emit an experimental warning when theimport()
is actually handled by the default loader through this option instead of requiring--experimental-vm-modules
.Contributed by Joyee Cheung in #51244
crypto: implement crypto.hash()
This patch introduces a helper crypto.hash() that computes
a digest from the input at one shot. This can be 1.2-2x faster
than the object-based createHash() for smaller inputs (<= 5MB)
that are readily available (not streamed) and incur less memory
overhead since no intermediate objects will be created.
Contributed by Joyee Cheung in #51044
Other Notable Changes
Commits
v21.6.2
: 2024-02-14, Version 21.6.2 (Current), @RafaelGSSCompare Source
Notable changes
This is a security release.
Notable changes
Commits
v21.6.1
: 2024-01-22, Version 21.6.1 (Current), @RafaelGSSCompare Source
Notable Changes
This release fixes a bug in
undici
using WebStreamsCommits
v21.6.0
: 2024-01-15, Version 21.6.0 (Current), @RafaelGSSCompare Source
New connection attempt events
Three new events were added in the
net.createConnection
flow:connectionAttempt
: Emitted when a new connection attempt is established. In case of Happy Eyeballs, this might emitted multiple times.connectionAttemptFailed
: Emitted when a connection attempt failed. In case of Happy Eyeballs, this might emitted multiple times.connectionAttemptTimeout
: Emitted when a connection attempt timed out. In case of Happy Eyeballs, this will not be emitted for the last attempt. This is not emitted at all if Happy Eyeballs is not used.Additionally, a previous bug has been fixed where a new connection attempt could have been started after a previous one failed and after the connection was destroyed by the user.
This led to a failed assertion.
Contributed by Paolo Insogna in #51045.
Changes to the Permission Model
Node.js 21.6.0 comes with several fixes for the experimental permission model and two new semver-minor commits.
We're adding a new flag
--allow-addons
to enable addon usage when using the Permission Model.Contributed by Rafael Gonzaga in #51183
And relative paths are now supported through the
--allow-fs-*
flags.Therefore, with this release one can use:
To give only read access to the entrypoint of the application.
Contributed by Rafael Gonzaga and Carlos Espa in #50758
Support configurable snapshot through
--build-snapshot-config
flagWe are adding a new flag
--build-snapshot-config
to configure snapshots through a custom JSON configuration file.When using this flag, additional script files provided on the command line will
not be executed and instead be interpreted as regular command line arguments.
These changes were contributed by Joyee Cheung and Anna Henningsen in #50453
Other Notable Changes
Commits
v21.5.0
: 2023-12-19, Version 21.5.0 (Current), @RafaelGSSCompare Source
Notable Changes
Deprecations
Commits
v21.4.0
: 2023-12-05, Version 21.4.0 (Current), @targosCompare Source
Notable Changes
This release fixes a regression introduced in v21.3.0 that caused the
fs.writeFileSync
method to throw when called with
'utf8'
encoding, no flag option, and if the target file didn't exist yet.Commits
v21.3.0
: 2023-11-30, Version 21.3.0 (Current), @RafaelGSSCompare Source
Notable Changes
New
--disable-warning
flagThis version adds a new
--disable-warning
option that allows users to disable specific warnings either by code(i.e. DEP0025) or type (i.e. DeprecationWarning, ExperimentalWarning).
This option works alongside existing
--warnings
and--no-warnings
.For example, the following script will not emit DEP0025
require('node:sys')
when executed withnode --disable-warning=DEP0025
:Contributed by Ethan-Arrowood in #50661
Update Root Certificates to NSS 3.95
This is the certdata.txt from NSS 3.95, released on 2023-11-16.
This is the version of NSS that will ship in Firefox 121 on
2023-12-19.
Certificates added:
Certificates removed:
A626340
Fast fs.writeFileSync with UTF-8 Strings
Enhanced writeFileSync functionality by implementing a highly efficient fast path primarily in C++ for UTF8-encoded string data.
Additionally, optimized the
appendFileSync
method by leveraging the improvedwriteFileSync
functionality.For simplicity and performance considerations, the current implementation supports only string data,
as benchmark results raise concerns about the efficacy of using Buffer for this purpose.
Future optimizations and expansions may be explored, but for now, the focus is on maximizing efficiency for string data operations.
Contributed by CanadaHonk in #49884.
Other Notable Changes
Commits
v21.2.0
: 2023-11-14, Version 21.2.0 (Current), @targosCompare Source
Notable Changes
Commits
v21.1.0
: 2023-10-24, Version 21.1.0 (Current), @targosCompare Source
Notable Changes
Automatically detect and run ESM syntax
The new flag
--experimental-detect-module
can be used to automatically runES modules when their syntax can be detected. For “ambiguous” files, which are
.js
or extensionless files with nopackage.json
with atype
field, Node.jswill parse the file to detect ES module syntax; if found, it will run the file
as an ES module, otherwise it will run the file as a CommonJS module.
The same applies to string input via
--eval
orSTDIN
.We hope to make detection enabled by default in a future version of Node.js.
Detection increases startup time, so we encourage everyone — especially package
authors — to add a
type
field topackage.json
, even for the default"type": "commonjs"
. The presence of atype
field, or explicit extensionssuch as
.mjs
or.cjs
, will opt out of detection.Contributed by Geoffrey Booth in #50096.
Other Notable Changes
Commits
v21.0.0
: 2023-10-17, Version 21.0.0 (Current), @RafaelGSS and @targosCompare Source
We're excited to announce the release of Node.js 21! Highlights include updates of the V8 JavaScript engine to 11.8,
stable
fetch
andWebStreams
, a new experimental flag to change the interpretation of ambiguous codefrom CommonJS to ES modules (
--experimental-default-type
), many updates to our test runner, and more!Node.js 21 will replace Node.js 20 as our ‘Current’ release line when Node.js 20 enters long-term support (LTS) later this month.
As per the release schedule, Node.js 21 will be ‘Current' release for the next 6 months, until April 2024.
Other Notable Changes
Semver-Major Commits
Semver-Minor Commits
Semver-Patch Commits
v20.18.0
: 2024-10-03, Version 20.18.0 'Iron' (LTS), @targosCompare Source
Notable Changes
Experimental Network Inspection Support in Node.js
This update introduces the initial support for network inspection in Node.js.
Currently, this is an experimental feature, so you need to enable it using the
--experimental-network-inspection
flag.With this feature enabled, you can inspect network activities occurring within a JavaScript application.
To use network inspection, start your Node.js application with the following command:
Please note that the network inspection capabilities are in active development.
We are actively working on enhancing this feature and will continue to expand its functionality in future updates.
http
andhttps
modules only.feature request on the Chrome DevTools side is addressed.
Contributed by Kohei Ueno in #53593 and #54246
Exposes X509_V_FLAG_PARTIAL_CHAIN to tls.createSecureContext
This releases introduces a new option to the API
tls.createSecureContext
. Fromnow on,
tls.createSecureContext({ allowPartialTrustChain: true })
can be usedto treat intermediate (non-self-signed) certificates in the trust CA certificate
list as trusted.
Contributed by Anna Henningsen in #54790
New option for vm.createContext() to create a context with a freezable globalThis
Node.js implements a flavor of
vm.createContext()
and friends that creates a context without contextifying its globalobject when vm.constants.DONT_CONTEXTIFY is used. This is suitable when users want to freeze the context
(impossible when the global is contextified i.e. has interceptors installed) or speed up the global access if they
don't need the interceptor behavior.
Contributed by Joyee Cheung in #54394
Deprecations
Other Notable Changes
Commits
v20.17.0
: 2024-08-21, Version 20.17.0 'Iron' (LTS), @marco-ippolitoCompare Source
module: support require()ing synchronous ESM graphs
This release adds
require()
support for synchronous ESM graphs underthe flag
--experimental-require-module
.If
--experimental-require-module
is enabled, and the ECMAScriptmodule being loaded by
require()
meets the following requirements:require()
will load the requested module as an ES Module, and returnthe module name space object. In this case it is similar to dynamic
import()
but is run synchronously and returns the name space objectdirectly.
Contributed by Joyee Cheung in #51977
path: add
matchesGlob
methodGlob patterns can now be tested against individual paths via the
path.matchesGlob(path, pattern)
method.Contributed by Aviv Keller in #52881
stream: expose DuplexPair API
The function
duplexPair
returns an array with two items,each being a
Duplex
stream connected to the other side:Whatever is written to one stream is made readable on the other. It provides
behavior analogous to a network connection, where the data written by the client
becomes readable by the server, and vice-versa.
Contributed by Austin Wright in #34111
Other Notable Changes
Commits
v20.16.0
: 2024-07-24, Version 20.16.0 'Iron' (LTS), @marco-ippolitoCompare Source
process: add process.getBuiltinModule(id)
process.getBuiltinModule(id)
provides a way to load built-in modulesin a globally available function. ES Modules that need to support
other environments can use it to conditionally load a Node.js built-in
when it is run in Node.js, without having to deal with the resolution
error that can be thrown by
import
in a non-Node.js environment orhaving to use dynamic
import()
which either turns the module intoan asynchronous module, or turns a synchronous API into an asynchronous one.
If
id
specifies a built-in module available in the current Node.js process,process.getBuiltinModule(id)
method returns the corresponding built-inmodule. If
id
does not correspond to any built-in module,undefined
is returned.
process.getBuiltinModule(id)
accepts built-in module IDs that are recognizedby
module.isBuiltin(id)
.The references returned by
process.getBuiltinModule(id)
always point tothe built-in module corresponding to
id
even if users modifyrequire.cache
so thatrequire(id)
returns something else.Contributed by Joyee Cheung in #52762
doc: doc-only deprecate OpenSSL engine-based APIs
OpenSSL 3 deprecated support for custom engines with a recommendation to switch to its new provider model.
The
clientCertEngine
option forhttps.request()
,tls.createSecureContext()
, andtls.createServer()
; theprivateKeyEngine
andprivateKeyIdentifier
fortls.createSecureContext();
andcrypto.setEngine()
all depend on this functionality from OpenSSL.Contributed by Richard Lau in #53329
inspector: fix disable async hooks on Debugger.setAsyncCallStackDepth
Debugger.setAsyncCallStackDepth
was previously calling the enable function by mistake. As a result, when profiling using Chrome DevTools, the async hooks won't be turned off properly after receivingDebugger.setAsyncCallStackDepth
with depth 0.Contributed by Joyee Cheung in #53473
Other Notable Changes
Commits
v20.15.1
: 2024-07-08, Version 20.15.1 'Iron' (LTS), @RafaelGSSCompare Source
This is a security release.
Notable Changes
Commits
v20.15.0
: 2024-06-20, Version 20.15.0 'Iron' (LTS), @marco-ippolitoCompare Source
test_runner: support test plans
It is now possible to count the number of assertions and subtests that are expected to run within a test. If the number of assertions and subtests that run does not match the expected count, the test will fail.
Contributed by Colin Ihrig in #52860
inspector: introduce the
--inspect-wait
flagThis release introduces the
--inspect-wait
flag, which allows debugger to wait for attachement. This flag is useful when you want to debug the code from the beginning. Unlike--inspect-brk
, which breaks on the first line, this flag waits for debugger to be connected and then runs the code as soon as a session is established.Contributed by Kohei Ueno in #52734
zlib: expose zlib.crc32()
This release exposes the crc32() function from zlib to user-land.
It computes a 32-bit Cyclic Redundancy Check checksum of data. If
value is specified, it is used as the starting value of the checksum,
otherwise, 0 is used as the starting value.
The CRC algorithm is designed to compute checksums and to detect error
in data transmission. It's not suitable for cryptographic authentication.
Contributed by Joyee Cheung in #52692
cli: allow running wasm in limited vmem with --disable-wasm-trap-handler
By default, Node.js enables trap-handler-based WebAssembly bound
checks. As a result, V8 does not need to insert inline bound checks
int the code compiled from WebAssembly which may speedup WebAssembly
execution significantly, but this optimization requires allocating
a big virtual memory cage (currently 10GB). If the Node.js process
does not have access to a large enough virtual memory address space
due to system configurations or hardware limitations, users won't
be able to run any WebAssembly that involves allocation in this
virtual memory cage and will see an out-of-memory error.
--disable-wasm-trap-handler
disables this optimization so thatusers can at least run WebAssembly (with a less optimial performance)
when the virtual memory address space available to their Node.js
process is lower than what the V8 WebAssembly memory cage needs.
Contributed by Joyee Cheung in #52766
Other Notable Changes
Commits
v20.14.0
: 2024-05-28, Version 20.14.0 'Iron' (LTS), @marco-ippolitoCompare Source
Notable Changes
Commits
v20.13.1
: 2024-05-09, Version 20.13.1 'Iron' (LTS), @marco-ippolitoCompare Source
2024-05-09, Version 20.13.1 'Iron' (LTS), @marco-ippolito
Revert "tools: install npm PowerShell scripts on Windows"
Due to a regression in the npm installation on Windows, this commit reverts the change that installed npm PowerShell scripts on Windows.
Commits
v20.13.0
: 2024-05-07, Version 20.13.0 'Iron' (LTS), @marco-ippolitoCompare Source
2024-05-07, Version 20.13.0 'Iron' (LTS), @marco-ippolito
buffer: improve
base64
andbase64url
performanceThe performance of the
base64
andbase64url
encoding and decoding functions has been improved significantly.Contributed by Yagiz Nizipli in #52428
crypto: deprecate implicitly shortened GCM tags
This release, introduces a doc-only deprecation of using GCM authentication tags that are shorter than the cipher's block size, unless the user specified the
authTagLength
option.Contributed by Tobias Nießen in #52345
events,doc: mark CustomEvent as stable
From this release
CustomEvent
has been marked stable.Contributed by Daeyeon Jeong in #52618
fs: add stacktrace to fs/promises
Sync functions in fs throwed an error with a stacktrace which is helpful for debugging. But functions in fs/promises throwed an error without a stacktrace. This commit adds stacktraces by calling
Error.captureStacktrace
and re-throwing the error.Contributed by 翠 / green in #49849
report: add
--report-exclude-network
optionNew option
--report-exclude-network
, also available asreport.excludeNetwork
, enables the user to exclude networking interfaces in their diagnostic report. On some systems, this can cause the report to take minutes to generate so this option can be used to optimize that.Contributed by Ethan Arrowood in #51645
src: add uv_get_available_memory to report and process
From this release it is possible to get the available memory in the system by calling
process.getAvailableMemory()
.Contributed by theanarkh #52023
stream: support typed arrays
This commit adds support for typed arrays in streams.
Contributed by IlyasShabi #51866
util: support array of formats in util.styleText
It is now possible to pass an array of format strings to
util.styleText
to apply multiple formats to the same text.Contributed by Marco Ippolito in #52040
v8: implement v8.queryObjects() for memory leak regression testing
This is similar to the queryObjects() console API provided by the Chromium DevTools console. It can be used to search for objects that have the matching constructor on its prototype chain in the heap after a full garbage collection, which can be useful for memory leak regression tests.
To avoid surprising results, users should avoid using this API on constructors whose implementation they don't control, or on constructors that can be invoked by other parties in the application.
To avoid accidental leaks, this API does not return raw references to the objects found. By default, it returns the count of the objects found. If options.format is 'summary', it returns an array containing brief string representations for each object. The visibility provided in this API is similar to what the heap snapshot provides, while users can save the cost of serialization and parsing and directly filer the target objects during the search.
We have been using this API internally for the test suite, which has been more stable than any other leak regression testing strategies in the CI. With a public implementation we can now use the public API instead.
Contributed by Joyee Cheung in #51927
watch: mark as stable
From this release Watch Mode is considered stable.
When in watch mode, changes in the watched files cause the Node.js process to restart.
Contributed by Moshe Atlow in #52074
Other Notable Changes
Commits
v20.12.2
: 2024-04-10, Version 20.12.2 'Iron' (LTS), @RafaelGSSCompare Source
This is a security release.
Notable Changes
child_process.spawn
without shell option enabled on WindowsCommits
v20.12.1
: 2024-04-03, Version 20.12.1 'Iron' (LTS), @RafaelGSSCompare Source
This is a security release
Notable Changes
Commits
v20.12.0
: 2024-03-26, Version 20.12.0 'Iron' (LTS), @richardlauCompare Source
Notable Changes
crypto: implement crypto.hash()
This patch introduces a helper crypto.hash() that computes
a digest from the input at one shot. This can be 1.2-2x faster
than the object-based createHash() for smaller inputs (<= 5MB)
that are readily available (not streamed) and incur less memory
overhead since no intermediate objects will be created.
Contributed by Joyee Cheung in #51044.
Loading and parsing environment variables
process.loadEnvFile(path)
:.env
file. If no path is specified, it automatically loads the .env file in the current directory. Example:process.loadEnvFile()
.process.loadEnvFile('./development.env')
.util.parseEnv(content)
:require('node:util').parseEnv('HELLO=world')
.Contributed by Yagiz Nizipli in #51476.
New connection attempt events
Three new events were added in the
net.createConnection
flow:connectionAttempt
: Emitted when a new connection attempt is established. In case of Happy Eyeballs, this might emitted multiple times.connectionAttemptFailed
: Emitted when a connection attempt failed. In case of Happy Eyeballs, this might emitted multiple times.connectionAttemptTimeout
: Emitted when a connection attempt timed out. In case of Happy Eyeballs, this will not be emitted for the last attempt. This is not emitted at all if Happy Eyeballs is not used.Additionally, a previous bug has been fixed where a new connection attempt could have been started after a previous one failed and after the connection was destroyed by the user.
This led to a failed assertion.
Contributed by Paolo Insogna in #51045.
Permission Model changes
Node.js 20.12.0 comes with several fixes for the experimental permission model and two new semver-minor commits.
We're adding a new flag
--allow-addons
to enable addon usage when using the Permission Model.Contributed by Rafael Gonzaga in #51183
And relative paths are now supported through the
--allow-fs-*
flags.Therefore, with this release one can use:
To give only read access to the entrypoint of the application.
Contributed by Rafael Gonzaga and Carlos Espa in #50758.
sea: support embedding assets
Users can now include assets by adding a key-path dictionary
to the configuration as the
assets
field. At build time, Node.jswould read the assets from the specified paths and bundle them into
the preparation blob. In the generated executable, users can retrieve
the assets using the
sea.getAsset()
andsea.getAssetAsBlob()
API.The single-executable application can access the assets as follows:
Contributed by Joyee Cheung in #50960.
Support configurable snapshot through
--build-snapshot-config
flagWe are adding a new flag
--build-snapshot-config
to configure snapshots through a custom JSON configuration file.When using this flag, additional script files provided on the command line will
not be executed and instead be interpreted as regular command line arguments.
These changes were contributed by Joyee Cheung and Anna Henningsen in #50453
Text Styling
util.styleText(format, text)
: This function returns a formatted text considering theformat
passed.A new API has been created to format text based on
util.inspect.colors
, enabling you to style text in different colors (such as red, blue, ...) and emphasis (italic, bold, ...).Contributed by Rafael Gonzaga in #51850.
vm: support using the default loader to handle dynamic import()
This patch adds support for using
vm.constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
as theimportModuleDynamically
option in all vm APIs that take this option exceptvm.SourceTextModule
. This allows users to have a shortcut to support dynamicimport()
in the compiled code without missing the compilation cache if they don't need customization of the loading process. We emit an experimental warning when theimport()
is actually handled by the default loader through this option instead of requiring--experimental-vm-modules
.Contributed by Joyee Cheung in #51244.
Root certificates updated to NSS 3.98
Certificates added:
Certificates removed:
Updated dependencies
Other notable changes
Commits
v20.11.1
: 2024-02-14, Version 20.11.1 'Iron' (LTS), @RafaelGSS prepared by @marco-ippolitoCompare Source
Notable changes
This is a security release.
Notable changes
Commits
v20.11.0
: 2024-01-09, Version 20.11.0 'Iron' (LTS), @UlisesGasconCompare Source
Notable Changes
Commits
v20.10.0
: 2023-11-22, Version 20.10.0 'Iron' (LTS), @targosCompare Source
Notable Changes
--experimental-default-type
flag to flip module defaultsThe new flag
--experimental-default-type
can be used to flip the defaultmodule system used by Node.js. Input that is already explicitly defined as ES
modules or CommonJS, such as by a
package.json
"type"
field or.mjs
/.cjs
file extension or the
--input-type
flag, is unaffected. What is currentlyimplicitly CommonJS would instead be interpreted as ES modules under
--experimental-default-type=module
:String input provided via
--eval
or STDIN, if--input-type
is unspecified.Files ending in
.js
or with no extension, if there is nopackage.json
filepresent in the same folder or any parent folder.
Files ending in
.js
or with no extension, if the nearest parentpackage.json
field lacks atype
field; unless the folder is inside anode_modules
folder.In addition, extensionless files are interpreted as Wasm if
--experimental-wasm-modules
is passed and the file contains the "magic bytes"Wasm header.
Contributed by Geoffrey Booth in #49869.
Detect ESM syntax in ambiguous JavaScript
The new flag
--experimental-detect-module
can be used to automatically run ESmodules when their syntax can be detected. For “ambiguous” files, which are
.js
or extensionless files with nopackage.json
with atype
field, Node.jswill parse the file to detect ES module syntax; if found, it will run the file
as an ES module, otherwise it will run the file as a CommonJS module. The same
applies to string input via
--eval
orSTDIN
.We hope to make detection enabled by default in a future version of Node.js.
Detection increases startup time, so we encourage everyone—especially package
authors—to add a
type
field topackage.json
, even for the default"type": "commonjs"
. The presence of atype
field, or explicit extensionssuch as
.mjs
or.cjs
, will opt out of detection.Contributed by Geoffrey Booth in #50096.
New
flush
option in file system functionsWhen writing to files, it is possible that data is not immediately flushed to
permanent storage. This allows subsequent read operations to see stale data.
This PR adds a
'flush'
option to thefs.writeFile
family of functions whichforces the data to be flushed at the end of a successful write operation.
Contributed by Colin Ihrig in #50009 and #50095.
Experimental WebSocket client
Adds a
--experimental-websocket
flag that adds aWebSocket
global, as standardized by WHATWG.
Contributed by Matthew Aitken in #49830.
vm: fix V8 compilation cache support for vm.Script
Previously repeated compilation of the same source code using
vm.Script
stopped hitting the V8 compilation cache after v16.x when support for
importModuleDynamically
was added tovm.Script
, resulting in a performanceregression that blocked users (in particular Jest users) from upgrading from
v16.x.
The recent fixes allow the compilation cache to be hit again
for
vm.Script
when--experimental-vm-modules
is not used even in thepresence of the
importModuleDynamically
option, so that users affected by theperformance regression can now upgrade. Ongoing work is also being done to
enable compilation cache support for
vm.CompileFunction
.Contributed by Joyee Cheung in #49950
and #50137.
Other notable changes
Commits
v20.9.0
: 2023-10-24, Version 20.9.0 'Iron' (LTS), @richardlauCompare Source
Notable Changes
This release marks the transition of Node.js 20.x into Long Term Support (LTS)
with the codename 'Iron'. The 20.x release line now moves into "Active LTS"
and will remain so until October 2024. After that time, it will move into
"Maintenance" until end of life in April 2026.
Known issue
Collecting code coverage via the
NODE_V8_COVERAGE
environment variable maylead to a hang. This is not thought to be a regression in Node.js 20 (some
reports are on Node.js 18). For more information, including some potential
workarounds, see issue #49344.
v20.8.1
: 2023-10-13, Version 20.8.1 (Current), @RafaelGSSCompare Source
This is a security release.
Notable Changes
The following CVEs are fixed in this release:
nghttp2
Security Release (High)undici
Security Release (High)More detailed information on each of the vulnerabilities can be found in October 2023 Security Releases blog post.
Commits
v20.8.0
: 2023-09-28, Version 20.8.0 (Current), @ruyadornoCompare Source
Notable Changes
Stream performance improvements
Performance improvements to writable and readable streams, improving the creation and destruction by ±15% and reducing the memory overhead each stream takes in Node.js
Contributed by Benjamin Gruenbaum in #49745 and Raz Luvaton in #49834.
Performance improvements for readable webstream, improving readable stream async iterator consumption by ±140% and improving readable stream
pipeTo
consumption by ±60%Contributed by Raz Luvaton in #49662 and #49690.
Rework of memory management in
vm
APIs with theimportModuleDynamically
optionThis rework addressed a series of long-standing memory leaks and use-after-free issues in the following APIs that support
importModuleDynamically
:vm.Script
vm.compileFunction
vm.SyntheticModule
vm.SourceTextModule
This should enable affected users (in particular Jest users) to upgrade from older versions of Node.js.
Contributed by Joyee Cheung in #48510.
Other notable changes
Commits
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Renovate Bot.
cc4bec4189
to96dc17e2b9
96dc17e2b9
to4d4f6ed0a9
4d4f6ed0a9
tod53ed1fce1
d53ed1fce1
to78cb1f4b67
78cb1f4b67
tod5ffb3588b
d5ffb3588b
toc74fa34f70
c74fa34f70
tod060cb0c66
d060cb0c66
to0f92f69e92
0f92f69e92
to904e5997ea
904e5997ea
to240fd5f2ae
240fd5f2ae
to22762d4778
22762d4778
to68ebea3774
68ebea3774
to7bccf979c9
7bccf979c9
toe4f68252a8
e4f68252a8
todb4638e7d3
db4638e7d3
toa26372e637
a26372e637
to401ec347c2
401ec347c2
to54d6b0ed2d
54d6b0ed2d
toc2f233ae67
c2f233ae67
toe06d6a28dc
e06d6a28dc
to317c044b23
317c044b23
to4486f101cb
4486f101cb
toe4c54ae2bd
e4c54ae2bd
tob02a033a60
b02a033a60
to6f9da089da
6f9da089da
tof6cd2ed03f
f6cd2ed03f
to70c3d6ce34
70c3d6ce34
toda90d895c3
da90d895c3
tobe6144d051
be6144d051
to880d81d752
880d81d752
to923586d214
923586d214
to482d5e2f45
482d5e2f45
to124f875305
124f875305
tof28999dc37
f28999dc37
to6f4055bdf0
6f4055bdf0
to9e6b4c6064
9e6b4c6064
toe9eb23cd2f
e9eb23cd2f
toc71c04f495
c71c04f495
to2f7cf388ad
2f7cf388ad
toe06ef70c9c
e06ef70c9c
toc173ed5658
Update Node.js to v22to Update node Docker tag to v22c173ed5658
toddcb05cf30
ddcb05cf30
to1957dacd0a
1957dacd0a
to4e5f612096
4e5f612096
tocfc6018907
cfc6018907
tof407ddeb97
f407ddeb97
to1305fd3ef1
1305fd3ef1
toa2314bc111
a2314bc111
tod88e96bf83
d88e96bf83
tofb631dac01
fb631dac01
tod652027813
Update node Docker tag to v22to Update Node.js to v22d652027813
tof1be09916b
f1be09916b
to9d0e0b89db
9d0e0b89db
tod9e94a127d
d9e94a127d
tof819dfc538
f819dfc538
to12c44f474d
12c44f474d
to959d7c446e
959d7c446e
toaddbb78782
addbb78782
toabb1574ef2
abb1574ef2
to62cba9af2a
62cba9af2a
to8baecde0c2
8baecde0c2
to0e759c3721
0e759c3721
to6c07b72492
Checkout
From your project repository, check out a new branch and test the changes.