Node.js reference architecture

The Red Hat Node.js team dedicates a lot of time to working in the Node.js community and contributing upstream. This is a quick update on some of the interesting things going on in the project as we start 2022.

Releases

The Node.js release schedule aims to be predictable so that consumers and users can plan their migrations. As per the schedule (Figure 1):

  • Node.js 12 will go end-of-life at the end of April 2022.
  • Node.js 14 and 16 are both in their long-term support phase and will be supported until April 2023 and April 2024 respectively.
  • Node.js 17 is our current release line and will be supported until June 2022.
Figure 1: The Node.js project has released a timeline for a couple upcoming releases (source: https://github.com/nodejs/release).

Also keeping with tradition, April will bring a new major version of Node.js: version 18. Preparations are already underway in the project to get things ready for the new release. The Node.js Build Working Group is planning for any required operating system and compiler upgrades. Early preview builds will likely be available in March.

New features

As always, contributors are working hard to bring new features to Node.js, listed as pull requests on GitHub. Here we detail a few recent additions.

HTTP fetch()

fetch() is going to happen! The experimental implementation of this long-awaited method has landed and shipped in Node.js 17.5.0. Global fetch() will be available initially only when you use the --experimental-fetch command-line option. The implementation is based upon undici, an HTTP/1.1 client written for Node.js by contributors to the project. A sample use is:

import {fetch} from 'undici';

async function fetchJson() {

    const res = await fetch('https://api.github.com/zen');

    console.log(res);

}

The shipping of this feature was accelerated in part by discussions in the most recent Node.js Next 10 mini-summit (January 2022), where the project defined and agreed on priorities for HTTP in Node.js. You can watch the discussion on YouTube or read the summary on GitHub.

ECMAScript modules

In recent months, the project has continued to make progress implementing ECMAScript modules. Key milestones include unflagging JSON modules. Although JSON modules remain experimental, they're now enabled by default as of Node.js 17.5.0.

Support for JSON import assertions has also been added, demonstrated by the following syntax:

import example from './example.json' assert { type: 'json' };

Other new features

Some other developments that show promise include:

Hot topics in the Node.js community

The Node.js project has a wide and varied collaborator base. This is one of its strengths and means that we have in-depth discussions before some decisions are made. Some of the interesting topics currently being discussed are listed in the following sections.

Primordials in Node.js core

Primordials are used in Node.js core in an effort to prevent tampering with the built-in Node.js modules, including from prototype pollution-type attacks.

Use of primordials in Node.js core has been an ongoing discussion within the project and the Node.js Technical Steering Committee (TSC). The discussion concerns the balance between how tamper-proof the core APIs should be, the value of being tamper-proof, and the costs in terms of code maintenance, runtime performance overhead, and the effort required to avoid regressions. This discussion continues, while the TSC has issued its first vote on what should be done in the error path.

Updating the toolchain used to build Node.js

Discussion about what tools we should use to build Node.js is heating up again. The current toolchain introduces some challenges, and the project would like to make a change. Some of the options appear in the following documents:

There is a call for interested people to help move this migration forward.

Next 10: The future of Node.js

The Node.js Next 10 group continues to work through the process of surfacing and documenting key technical priorities for the project. The team led two mini-summits recently. One took place in November 2021 to cover suitable types for end-users and single executable applications. Another took place in January 2022 to topics covered modern HTTP implementations and documentation.

We've had good engagement in these two summits, leading to some concrete outcomes. As an example, thanks to the HTTP discussions, as mentioned earlier, fetch() is now an experimental API. We also agreed to explore updating the style guide to allow us to generate better JSON documentation that can be used to generate type information more easily.

If you want to help Node.js be successful going forward, the Next 10 group is a great way to do so. You can participate in our GitHub repository and attend the Next 10 meetings and mini-summit, which can be found in the Node.js Project Meeting Calendar.

Catch up with the Node.js Next 10 mini-summit recordings:

Recent and upcoming events

While it's still a challenge to travel to conferences, we are hopeful that things will be better when the time comes for OpenJS World, Austin in June 2022. Our team has made several submissions to the conference and hopes to be able to see you at both the event and the Node.js Collaborator Summit in the following few days for a long-delayed reunion. In the meantime, we've been presenting virtually at DevConf.cz, and we'll also be speaking on Navigating the npm Ecosystem in the Enterprise at the upcoming CityJS Conference, London on March 25, 2022.

Stay up to date on Node.js

We hope you enjoyed our short update on what's going on in the Node.js community. If you want to read more, check out:

Comments