28th December 2021
Explore Node.js Resources by NearFormers in 2021
At NearForm we use Node.js in a lot of client projects. We actively support and contribute to Node.js and NearForm’s Chief Software Architect Matteo Collina is on the Node.js Technical Steering Committee (TSTC).
By having our hands on the pulse of what’s new and upcoming in Node we can be more agile and prepare for future changes before a new long-term support (LTS) version is released. We pass this knowledge along to our clients as we work together to build amazing digital products.
In this special end of the year post, we’ll take a look back at some resources NearFormers provided to the open source community about Node.js this year.
Node.js Version 16 Enters LTS Phase
Node.js releases a new long-term support version every 2 years. After 6 months in “active” status, even-numbered Node versions move to LTS which means that they will receive critical bug fixes for 30 months. This gives developers a chance to prepare their applications for upgrading to new versions.
In 2021 Node.js 16, codenamed Gallium, entered its LTS phase and brought along with it some new features and functionality. Some of the new features introduced in version 16 include:
- Platform Support
- Node-API Version 8
- Stable Timers Promises API
- Web Crypto API
- Abort Controller
- Buffer atob and btoa
- Npm version 7
- Builds for Apple Silicon Processors
8 Valuable Node.js Resources Provided by NearFormers in 2021
As our developers are constantly working on or with Node.js they have a lot of insights into best practices and new features and produce some great resources for the Node.js community. We welcome you to take a look through some of the resources NearFormers have provided to the community this year.
1. Adventures in Nodeland – Newsletter
NearFormer and Node TSTC member Matteo Collina publishes the weekly “Adventures in Nodeland” newsletter about some of the interesting things he’s working on including Node, Fastify, Pino, GraphQL and Undici among other things. Matteo started the newsletter in March and has enjoyed a steady growth in readership since its inception.
“I write about my journey as a core contributor of Node.js, as an author and a maintainer of many modules – including Fastify and Pino.” Matteo Collina
Matteo tackles some highly technical issues and the topics discussed are mainly targeted at developers for this newsletter. It’s an invaluable resource for anyone currently working with or interested in learning about Node.js.
2. Optimise Node.js by Avoiding Broken Promises – Blog Post
In June former NearFormer and current member of the Node.js TSTC, James Snell, wrote an invaluable piece on avoiding broken promises in Node.js. The basis for this article stems from a workshop, incidentally titled “Broken Promises”, that Matteo and James offer to developers to help with optimising Node.js applications.
“I want to… help folks better understand one of the most critical aspects of Node.js performance: Understanding how Node.js schedules asynchronous execution.” James Snell
In the article James explains in detail how the Node.js event loop works and how to use promises correctly in Node.js.
3. Doing TypeScript without TypeScript – NodeConf Remote Talk
Simone Sanfratello, a Backend Engineer at NearForm, delivered one of the most popular talks at this year’s NodeConf Remote. As of the time of publication the video has been viewed over 4400 times on YouTube.
“We get the IDE support. We get type checking. And we get that only using type notation with JSdoc.” Simone Sanfratello
4. Using Abort Signal in Node.js – Blog Post
In July James Snell wrote an important piece about how to use the AbortSignal and AbortController APIs properly to avoid unnecessary performance issues. James dives deep into how promises work in Node.js and how to cancel asynchronous operations in the Node core API.
“The AbortController and AbortSignal APIs are quickly becoming the standard mechanism for cancelling asynchronous operations in the Node.js core API.” James Snell
5. Multi-threaded Logging with Pino – NodeConf Remote Talk
Pino author and maintainer Matteo Collina offers a deep dive into using Pino for multi-threaded logging. Ever conscious of achieving optimal performance in the Node.js applications he builds Matteo created Pino, the fastest logger for Node.js, with performance in mind.
In this video Matteo looks at why devs should use multi-threaded logging, what it is, why it is important and how to do it with Pino.
“Logging is actually a significant bottleneck for most applications. The more you log, the more your applications slow down.” Matteo Collina
6. Introducing New Crypto Capabilities in Node.js – Blog Post
In this post from July, James Snell explores the new crypto functionalities available in Node.js. James breaks down how uuids are generated, explains why this functionality was introduced to Node and shows us how to use the new capabilities to construct random uuids. Additionally he shows how to generate and check primes in Node applications.
“Because generating reliably unique identifiers can be a performance bottleneck in many applications, doing so as quickly and as efficiently as possible is critical. Improving the performance of random UUID generation was one of the critical requirements of the new Node.js implementation.” James Snell
7. Mélodie: a Journey from Svelte to Fastify – NodeConf Remote Talk
“Adding or implementing features is not really the challenge. The challenge is keeping the productivity high as the codebase grows.” Damien Simonin Feugas
8. Managing Load in Node.js with under-pressure – Blog Post
NearForm Engineering manager Simone Busoli walks devs through a simple mechanism for detecting load in Node.js applications and implementing a circuit breaker to preserve the health of the application and minimise the impact that a slowdown will have on the system. Since Node.js doesn’t have a built-in mechanism to avoid load it’s important to find better ways to handle increasing workloads.
“In a radical departure from the programming models of mainstream web servers such as Apache and Microsoft’s IIS, Node.js introduced reliance on a single thread for multiple requests…The Node.js approach has proven itself to be blazingly fast for a large set of use-cases needed by modern web applications.” Simone Busoli
Looking ahead to 2022
NodeConf was held remotely this year due to the pandemic but we are optimistic that we will be able to host an in-person NodeConf again this year after a 2-year hiatus. We’ll continue to contribute to Node core and provide the open source community with resources for understanding and using Node.js with an eye on performance.