Update Node.js to v21 #327
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "renovate/node-21.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
->21.7.3-bullseye-slim
Release Notes
nodejs/node (node)
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
v20.7.0
: 2023-09-18, Version 20.7.0 (Current), @UlisesGasconCompare Source
Notable Changes
Commits
v20.6.1
: 2023-09-08, Version 20.6.1 (Current), @ruyadorno and @RafaelGSSCompare Source
Commit
v20.6.0
: 2023-09-04, Version 20.6.0 (Current), @juanarbol prepared by @UlisesGasconCompare Source
Notable changes
built-in
.env
file supportStarting from Node.js v20.6.0, Node.js supports
.env
files for configuring environment variables.Your configuration file should follow the INI file format, with each line containing a key-value pair for an environment variable.
To initialize your Node.js application with predefined configurations, use the following CLI command:
node --env-file=config.env index.js
.For example, you can access the following environment variable using
process.env.PASSWORD
when your application is initialized:In addition to environment variables, this change allows you to define your
NODE_OPTIONS
directly in the.env
file, eliminating the need to include it in yourpackage.json
.This feature was contributed by Yagiz Nizipli in #48890.
import.meta.resolve
unflaggedIn ES modules,
import.meta.resolve(specifier)
can be used to get an absolute URL string to whichspecifier
resolves, similar torequire.resolve
in CommonJS. This aligns Node.js with browsers and other server-side runtimes.This feature was contributed by Guy Bedford in #49028
New
node:module
APIregister
for module customization hooks; newinitialize
hookThere is a new API
register
available onnode:module
to specify a file that exports module customization hooks, and pass data to the hooks, and establish communication channels with them. The “define the file with the hooks” part was previously handled by a flag--experimental-loader
, but when the hooks moved into a dedicated thread in 20.0.0 there was a need to provide a way to communicate between the main (application) thread and the hooks thread. This can now be done by callingregister
from the main thread and passing data, includingMessageChannel
instances.We encourage users to migrate to an approach that uses
--import
withregister
, such as:Using
--import
ensures that the customization hooks are registered before any application code runs, even the entry point.This feature was contributed by Izaak Schroeder in #48842 and #48559
Module customization
load
hook can now support CommonJSAuthors of module customization hooks can how handle both ES module and CommonJS sources in the
load
hook. This works for CommonJS modules referenced via eitherimport
orrequire
, so long as the main entry point of the application is handled by the ES module loader (such as because the entry point is an ES module file, or if the--import
flag is passed). This should simplify the customization of the Node.js module loading process, as package authors can customize more of Node.js without relying on deprecated APIs such asrequire.extensions
.This feature was contributed by Antoine du Hamel in #47999
Node.js C++ addons now have experimental support for cppgc (Oilpan), a C++ garbage collection library in V8.
Now when Node.js starts up, it makes sure that there is a
v8::CppHeap
attached to the V8 isolate. This enables users to allocate in thev8::CppHeap
using<cppgc/*>
headers from V8, which are now also included into the Node.js headers available to addons. Note that since Node.js only bundles the cppgc library coming from V8, the ABI stability of cppgc is currently not guaranteed in semver-minor and -patch updates, but we do not expect the ABI to break often, as it has been stable and battle-tested in Chromium for years. We may consider including cppgc into the ABI stability guarantees when it gets enough adoption internally and externally.To help addon authors create JavaScript-to-C++ references of which V8's garbage collector can be aware, a helper function
node::SetCppgcReference(isolate, js_object, cppgc_object)
has been added tonode.h
. V8 may provide a native alternative in the future, which could then replace this Node.js-specific helper. In the mean time, users can use this API to avoid having to hard-code the layout of JavaScript wrapper objects. An example of how to create garbage-collected C++ objects in the unified heap and wrap it in a JavaScript object can be found in the Node.js addon tests.The existing
node::ObjectWrap
helper would continue to work, while cppgc-based object management serves as an alternative with some advantages mentioned in the V8 blog post about Oilpan.This feature was contributed by Daryl Haresign and Joyee Cheung in #48660 and #45704.
Other notable changes
Commits
v20.5.1
: 2023-08-09, Version 20.5.1 (Current), @RafaelGSSCompare Source
This is a security release.
Notable Changes
The following CVEs are fixed in this release:
More detailed information on each of the vulnerabilities can be found in August 2023 Security Releases blog post.
Commits
v20.5.0
: 2023-07-18, Version 20.5.0 (Current), @juanarbolCompare Source
Notable Changes
Commits
v20.4.0
: 2023-07-05, Version 20.4.0 (Current), @RafaelGSSCompare Source
Notable Changes
Mock Timers
The new feature allows developers to write more reliable and predictable tests for time-dependent functionality.
It includes
MockTimers
with the ability to mocksetTimeout
,setInterval
fromglobals
,node:timers
, andnode:timers/promises
.The feature provides a simple API to advance time, enable specific timers, and release all timers.
This feature was contributed by Erick Wendel in #47775.
Support to the explicit resource management proposal
Node is adding support to the explicit resource management
proposal to its resources allowing users of TypeScript/babel to use
using
/await using
withV8 support for everyone else on the way.
This feature was contributed by Moshe Atlow and Benjamin Gruenbaum in #48518.
Other notable changes
Commits
v20.3.1
: 2023-06-20, Version 20.3.1 (Current), @RafaelGSSCompare Source
This is a security release.
Notable Changes
The following CVEs are fixed in this release:
mainModule.__proto__
Bypass Experimental Policy Mechanism (High)More detailed information on each of the vulnerabilities can be found in June 2023 Security Releases blog post.
Commits
v20.3.0
: 2023-06-08, Version 20.3.0 (Current), @targosCompare Source
Notable Changes
Commits
v20.2.0
: 2023-05-16, Version 20.2.0 (Current), @targosCompare Source
Notable Changes
Commits
v20.1.0
: 2023-05-03, Version 20.1.0 (Current), @targosCompare Source
Notable Changes
Commits
v20.0.0
: 2023-04-18, Version 20.0.0 (Current), @RafaelGSSCompare Source
We're excited to announce the release of Node.js 20! Highlights include the new Node.js Permission Model,
a synchronous
import.meta.resolve
, a stable test_runner, updates of the V8 JavaScript engine to 11.3, Ada to 2.0,and more!
As a reminder, Node.js 20 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.
Notable Changes
Permission Model
Node.js now has an experimental feature called the Permission Model.
It allows developers to restrict access to specific resources during program execution, such as file system operations,
child process spawning, and worker thread creation.
The API exists behind a flag
--experimental-permission
which when enabled will restrict access to all available permissions.By using this feature, developers can prevent their applications from accessing or modifying sensitive data or running potentially harmful code.
More information about the Permission Model can be found in the Node.js documentation.
The Permission Model was a contribution by Rafael Gonzaga in #44004.
Custom ESM loader hooks run on dedicated thread
ESM hooks supplied via loaders (
--experimental-loader=foo.mjs
) now run in a dedicated thread, isolated from the main thread.This provides a separate scope for loaders and ensures no cross-contamination between loaders and application code.
Synchronous
import.meta.resolve()
In alignment with browser behavior, this function now returns synchronously.
Despite this, user loader
resolve
hooks can still be defined as async functions (or as sync functions, if the author prefers).Even when there are async
resolve
hooks loaded,import.meta.resolve
will still return synchronously for application code.Contributed by Anna Henningsen, Antoine du Hamel, Geoffrey Booth, Guy Bedford, Jacob Smith, and Michaël Zasso in #44710
V8 11.3
The V8 engine is updated to version 11.3, which is part of Chromium 113.
This version includes three new features to the JavaScript API:
The V8 update was a contribution by Michaël Zasso in #47251.
Stable Test Runner
The recent update to Node.js, version 20, includes an important change to the test_runner module. The module has been marked as stable after a recent update.
Previously, the test_runner module was experimental, but this change marks it as a stable module that is ready for production use.
Contributed by Colin Ihrig in #46983
Ada 2.0
Node.js v20 comes with the latest version of the URL parser, Ada. This update brings significant performance improvements
to URL parsing, including enhancements to the
url.domainToASCII
andurl.domainToUnicode
functions innode:url
.Ada 2.0 has been integrated into the Node.js codebase, ensuring that all parts of the application can benefit from the
improved performance. Additionally, Ada 2.0 features a significant performance boost over its predecessor, Ada 1.0.4,
while also eliminating the need for the ICU requirement for URL hostname parsing.
Contributed by Yagiz Nizipli and Daniel Lemire in #47339
Preparing single executable apps now requires injecting a Blob
Building a single executable app now requires injecting a blob prepared by
Node.js from a JSON config instead of injecting the raw JS file.
This opens up the possibility of embedding multiple co-existing resources into the SEA (Single Executable Apps).
Contributed by Joyee Cheung in #47125
Web Crypto API
Web Crypto API functions' arguments are now coerced and validated as per their WebIDL definitions like in other Web Crypto API implementations.
This further improves interoperability with other implementations of Web Crypto API.
This change was made by Filip Skokan in #46067.
Official support for ARM64 Windows
Node.js now includes binaries for ARM64 Windows, allowing for native execution on the platform.
The MSI, zip/7z packages, and executable are available from the Node.js download site along with all other platforms.
The CI system was updated and all changes are now fully tested on ARM64 Windows, to prevent regressions and ensure compatibility.
ARM64 Windows was upgraded to tier 2 support by Stefan Stojanovic in #47233.
WASI version must now be specified
When
new WASI()
is called, the version option is now required and has no default value.Any code that relied on the default for the version will need to be updated to request a specific version.
This change was made by Michael Dawson in #47391.
Deprecations and Removals
url.parse()
accepts URLs with ports that are not numbers. This behavior might result in host name spoofing with unexpected input.These URLs will throw an error in future versions of Node.js, as the WHATWG URL API does already.
Starting with Node.js 20, these URLS cause
url.parse()
to emit a warning.Semver-Major Commits
Semver-Minor Commits
Semver-Patch Commits
v19.9.0
: 2023-04-10, Version 19.9.0 (Current), @RafaelGSSCompare Source
Notable Changes
Tracing Channel in diagnostic_channel
TracingChannel
adds a new, high-performance channel to publish tracing data about the timing and purpose of function executions.Contributed by Stephen Belanger in #44943
New URL.canParse API
A new API was added to the URL.
URL.canParse
checks if aninput
with an optional base value can be parsed correctlyaccording to WHATWG URL specification.
Contributed by Khafra in #47179
Other notable changes
events:
msi:
node-api:
stream:
test_runner:
Commits
v19.8.1
: 2023-03-15, Version 19.8.1 (Current), @targosCompare Source
Notable Changes
This release contains a single revert of a change that was introduced in v19.8.0
and introduced application crashes.
Fixes: #47096
Commits
v19.7.0
: 2023-02-21, Version 19.7.0 (Current), @MylesBorinsCompare Source
Notable Changes
Commits
v19.6.1
: 2023-02-16, Version 19.6.1 (Current), @RafaelGSSCompare Source
This is a security release.
Notable Changes
The following CVEs are fixed in this release:
process.mainModule.require
(High)More detailed information on each of the vulnerabilities can be found in February 2023 Security Releases blog post.
This security release includes OpenSSL security updates as outlined in the recent
OpenSSL security advisory and
undici
security update.Commits
v19.6.0
: 2023-02-02, Version 19.6.0 (Current), @ruyadornoCompare Source
Notable changes
ESM: Leverage loaders when resolving subsequent loaders
Loaders now apply to subsequent loaders, for example:
--experimental-loader ts-node --experimental-loader loader-written-in-typescript
.Upgrade npm to 9.4.0
Added
--install-strategy=linked
option for installations similar to pnpm.Other notable changes
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.
2d610474fe
to53e84dff8f
53e84dff8f
to758a4cf57d
758a4cf57d
todc73c70c7a
dc73c70c7a
toe0c02a9418
e0c02a9418
to20a1421e6f
20a1421e6f
to496d40a424
496d40a424
tob7123374a9
b7123374a9
toaca5428089
aca5428089
to5cc6aaeeb1
5cc6aaeeb1
tobdfe75026f
bdfe75026f
to7fa7b55b2e
7fa7b55b2e
to7697e4b6b3
7697e4b6b3
to621af8c840
621af8c840
toa178527998
a178527998
to73c5f0ee4e
73c5f0ee4e
tofa34694641
fa34694641
to59661db84f
59661db84f
to94af085c6a
94af085c6a
to433cb6bc07
433cb6bc07
toa1bcde5075
a1bcde5075
to0f363ab329
0f363ab329
toa0cb6be217
a0cb6be217
to240d18d064
240d18d064
to8c34e69b47
8c34e69b47
to73cf812b02
73cf812b02
to2b4937ca09
2b4937ca09
to25d78a53c3
25d78a53c3
to9457d1b15f
9457d1b15f
to5a050d676b
5a050d676b
to1d66882e5f
1d66882e5f
todede6d7284
dede6d7284
to95690da8aa
95690da8aa
to5fbe537860
5fbe537860
tod6c04d1b73
d6c04d1b73
to854999dd78
854999dd78
to0925ea6209
0925ea6209
to5249c7ae51
5249c7ae51
toab4a97224a
ab4a97224a
to1693347a88
c97cf9c31f
to059f60f8f1
059f60f8f1
tod677cfb723
d677cfb723
to7ceff44852
7ceff44852
tod3bb5b5f9e
d3bb5b5f9e
tob621e825ad
b621e825ad
to4f99318b88
4f99318b88
to6151db10bf
6151db10bf
to3ad96bad98
3ad96bad98
to1a58251e4c
1a58251e4c
to140e84dcd6
140e84dcd6
tod18324149a
d18324149a
to6703ab0647
6703ab0647
to3403c2971c
3403c2971c
to428b02b53f
428b02b53f
to5889843d6b
5889843d6b
to1ced12ddce
1ced12ddce
tof89fac8556
f89fac8556
tobc4c90f810
bc4c90f810
to76bd6e1dd6
76bd6e1dd6
toc009b01a49
c009b01a49
tof28c2fe538
f28c2fe538
to527f47a64b
527f47a64b
to36319c4bb6
36319c4bb6
to072965831f
072965831f
to738239aecc
738239aecc
to54a6ed3692
54a6ed3692
to0caf8751c5
0caf8751c5
tocd4ebf18d0
cd4ebf18d0
to7defd3fcc3
7defd3fcc3
to8237590456
8237590456
to1445688f11
1445688f11
to0d37d34084
0d37d34084
to86e36b5486
86e36b5486
to77d49d94c7
77d49d94c7
to03852efb3d
03852efb3d
toba35dd8ecc
ba35dd8ecc
to4eba126bf9
4eba126bf9
to45b60d956d
45b60d956d
to70d7dfa961
70d7dfa961
to06bd8ca4aa
06bd8ca4aa
to1f780bbafb
1f780bbafb
to5265c6b1a0
5265c6b1a0
to25f7249513
25f7249513
to6c552fcd29
6c552fcd29
to75bf39473c
75bf39473c
toa5fb281c71
a5fb281c71
toed3f5fc78a
ed3f5fc78a
to88726875f2
Update Node.js to v21to Update node Docker tag to v21Update node Docker tag to v21to Update Node.js to v21Checkout
From your project repository, check out a new branch and test the changes.