JavaScript runtime Node.js 19 keeps the HTTP connection alive and replaces Nodemon!

Photo by Markus Winkler / Unsplash

JavaScript runtime Node.js 19 keeps the HTTP connection alive and replaces Nodemon!

In addition to enabling keep-alive for HTTP by default, Node.js can perform an automatic restart when important files are changed.

Paul Knulst  in  JavaScript Oct 19, 2022 2 min read

Yesterday Node.js 19 has been made available by the Node.js community, six months after version 18. A new experimental feature that restarts the process when significant files are updated is included in the most recent version of the open-source JavaScript runtime environment. Additionally, HTTP's keep-alive feature is immediately turned on.

Several changes have been made internally: Versions 10.7 of the JavaScript engine V8 and 8.1.0 of the llhttp library, which handle HTTP processing, are now used in the runtime environment.

Node.js 18, which was published in April, will enter long-term support (LTS) the following week in accordance with the release. Running for a total of three years, the even version numbers in Runtime transition to the LTS phase with the release of the odd ones, while the odd ones reach their end of life (EOL) with the release of the subsequent even number. So, Node.js 18 will be supported until April 30, 2025, while Node.js 19 will only be supported until June 1, 2023.

Connection on hold

This new version (Node.js 19) enables keepAlive by default. Outgoing HTTP(S) connections are subject to the keep-alive feature included in HTTP/1.1, which reuses the current connection and often increases performance. The timeout is set by default to 5 seconds.

Better performance will result from enabling keepAlive since connections are reused by default.

Additionally, the agent may now interpret any response keepAlive messages that the servers may send. The client is told how long to stay connected via this header. On the other hand, when the close() method is used, the Node.js HTTP server will now immediately disconnect inactive clients (who are utilizing HTTP Keep-Alive to re-use the connection).

Furthermore, there may be a default improvement in throughput/performance for Node.js HTTP(S)/1.1 requests.

Crypto is now Stable!

Node.js 19 stabilizes the WebCrypto API, which can be used by globalThis.crypto or require('node:crypto').webcrypto (with an exception if using the following algorithms: X448, X25519, Ed448, and Ed25519)

Watch Mode available

Strictly speaking, the (almost) new command line parameter --watch, which is still marked as experimental, has already made it into the 18 series of the runtime environment, which has been known since version 18.11. If it is active, Runtime checks a file for changes and, if so, restarts the process. It can be activated when a file is run by:

node --watch index.js

Closing Notes

A fast update on new important changes within the new Node.js version. As the latest LTS version 16 will be deprecated next year you should consider updating to either 18 LTS or 19. This process could cause severe damage to your apps and you should as early as possible.

My suggestion: Start now!

Also, beyond the innovations, it is worth noting that Node.js 19 no longer offers a connection for the analysis tools DTrace, SystemTap, and ETW (Event Tracing for Windows). Keeping the interaction with the tools up to date is obviously too complex.

Feel free to connect with me on Medium, LinkedIn, Twitter, and GitHub.

🙌 Support this content

If you like this content, please consider supporting me. You can share it on social media, buy me a coffee, or become a paid member. Any support helps.

See the contribute page for all (free or paid) ways to say thank you!

Thanks! 🥰

By Paul Knulst

I'm a husband, dad, lifelong learner, tech lover, and Senior Engineer working as a Tech Lead. I write about projects and challenges in IT.