What Is New in Node.js 9?
| Category | Change |
|---|---|
| New Features | http2 module (experimental) |
| New Features | util.promisify() -- convert callback APIs to promises |
| Improvements | V8 6.2 -- async iteration, Object rest/spread properties |
| Improvements | Error codes introduced across Node.js core |
| Improvements | assert: strict mode added (assert.strict) |
| Improvements | cluster: worker disconnect timeout option |
| Security | OpenSSL 1.0.2n |
util.promisify() -- Instant Promise Wrappers for Callbacks
util.promisify() wraps any Node.js callback-style function (that follows the (err, value) convention) into a promise-returning function. This bridged the gap while the ecosystem migrated from callbacks to async/await.
import { promisify } from 'node:util';
import { readFile } from 'node:fs';
const readFileAsync = promisify(readFile);
const content = await readFileAsync('./config.json', 'utf8');
Many Node.js built-ins also expose a [util.promisify.custom] symbol for customized behavior when promisified.
HTTP/2 Module (Experimental)
Node.js 9 ships an experimental http2 module implementing the HTTP/2 protocol (RFC 7540). HTTP/2 provides multiplexing, header compression (HPACK), and server push -- all over a single TCP connection.
import http2 from 'node:http2';
const server = http2.createSecureServer({ key, cert });
server.on('stream', (stream, headers) => {
stream.respond({ ':status': 200 });
stream.end('Hello HTTP/2');
});
The module is experimental in v9 and stabilizes in Node.js 10. For production use, prefer v10+ or frameworks like Fastify that abstract over both HTTP/1.1 and HTTP/2.
assert.strict -- Strict Equality by Default
assert.strict provides a version of the assert module where all comparisons use strict equality (===). The legacy assert.equal() uses abstract equality (==), which causes surprising failures. Switching to assert.strict makes test assertions more predictable.
FAQ
Is Node.js 9 an LTS release?
No. Node.js 9 is a Current release that reached end-of-life in June 2018. The concurrent LTS was Node.js 8.
Can util.promisify() wrap third-party callback libraries?
Yes, as long as the callback signature is (err, result). For libraries that use non-standard callback shapes, use the [util.promisify.custom] symbol or write a manual wrapper.
Does HTTP/2 require HTTPS?
In browsers, yes -- HTTP/2 is only negotiated over TLS (h2). The Node.js http2 module also supports h2c (HTTP/2 over cleartext) using http2.createServer(), but browsers do not use this. For server-to-server communication cleartext h2c works fine.
What is Object rest/spread in V8 6.2?const { a, ...rest } = obj and const full = { ...defaults, ...overrides } became natively available. Previously these required Babel's object rest/spread plugin.
Are error codes backward compatible?
New error codes were added across v9/v10. Existing error messages are kept for human readability but the code property is now the stable, machine-readable identifier you should check in error handling logic.