Experimental Network Inspection Arrives in Node.js - aspirestream.ltd

Experimental Network Inspection Arrives in Node.js

October 8, 2024 Arnold 0 Comments

The latest release of Node.js introduces a new experimental feature for inspecting network activities, marking an exciting development for the widely-used JavaScript runtime.

With the release of Node.js v20.18.0 on October 3, developers now have access to preliminary support for network inspection, although it’s currently focused on HTTP and HTTPS protocols. To leverage this feature, users need to launch Node.js with the following command:
$ node --inspect-wait --experimental-network-inspection index.js

This inspection tool is still in its early stages of development and is expected to expand to other protocols in future updates.

Additional Features in Node.js v20.18.0

Beyond network inspection, Node.js 20.18.0 comes packed with other useful enhancements.

One significant update is to the tls.createSecureContext API. A new option allows developers to treat non-self-signed certificates as trusted within a trusted CA certificate list. This can be activated using the following code:

tls.createSecureContext({allowPartialTrustChain: true});

This option is particularly helpful in environments where certificate validation might be more complex or nuanced.

Another notable addition is a modification to the vm.createContext() function. This update provides the ability to create a context with a “freezable” globalThis. When the vm.constants.DONT_CONTEXTIFY option is applied, the global object in the context will not be “contextified.” According to the release notes, this can improve performance, especially when developers wish to freeze the context or avoid the overhead introduced by global interception.

These improvements highlight Node.js’s ongoing commitment to providing developers with more powerful and efficient tools for building scalable applications.

leave a comment