What Is New in Node.js 12?
| Category | Change |
|---|---|
| New Features | V8 7.4 -- async stack traces, faster async/await |
| New Features | TLS 1.3 support |
| New Features | Heap dump on --heapsnapshot-near-heap-limit |
| New Features | ES6 module support (experimental, opt-in) |
| Improvements | Default HTTP parser changed to llhttp |
| Improvements | Workers (worker_threads) stabilized |
| Improvements | Startup performance improved via V8 code cache |
| Security | TLS: system CA certificates honored by default |
Faster async/await and Async Stack Traces
V8 7.4 rewrites the async/await implementation. In V8 6.x, awaiting a non-promise value inside an async function had unnecessary overhead. V8 7.4 makes this path almost as fast as sync code, which improves throughput in async-heavy Express/Koa route handlers noticeably.
Async stack traces now show the correct call chain through awaits, instead of stopping at the first await boundary. Debugging async errors in production finally shows the full path from the origin call.
Worker Threads Stabilized
worker_threads moves from experimental to a stable (but not fully stable) status in Node.js 12. You can run CPU-heavy tasks in separate threads with shared memory via SharedArrayBuffer.
import { Worker, isMainThread, workerData } from 'node:worker_threads';
if (isMainThread) {
const worker = new Worker('./image-resize.js', { workerData: { path: './img.png' } });
worker.on('message', (result) => console.log('Done:', result));
} else {
// CPU-heavy work here, does not block the main event loop
}
llhttp HTTP Parser
Node.js 12 switches from the legacy http_parser (C) to llhttp as the default HTTP parser. llhttp is generated from TypeScript specification, making it maintainable and easier to validate for correctness. It is also strictly faster in benchmarks.
This should be transparent to most users. If you use custom HTTP parsers or raw TCP connections that depend on parser quirks, verify compatibility.
Startup Performance via V8 Code Cache
Node.js 12 generates V8 code cache at build time for built-in libraries. This cuts startup time significantly for small scripts and CLI tools -- a welcome improvement for developers who run short-lived scripts frequently.
FAQ
Is Node.js 12 an LTS release?
Yes. Node.js 12 (codename "Erbium") was an LTS release with support ending April 2022. It is fully end-of-life.
Is worker_threads suitable for I/O-bound work?
Not really. Workers shine for CPU-bound tasks (video encoding, image processing, crypto). For I/O, Node's event loop handles it efficiently without threads -- adding threads for I/O adds overhead with minimal benefit.
Does the llhttp switch change how HTTP responses are parsed?
It is stricter in some edge cases (e.g., malformed header handling). If you have HTTP clients or servers sending technically invalid HTTP, you may see parsing errors that were previously silently accepted.
Can I use ES modules without a flag in Node.js 12?
No -- ESM is behind --experimental-modules in Node.js 12. Full ESM support without flags arrives in Node.js 14.
What is the --heapsnapshot-near-heap-limit flag for?
It automatically writes a heap snapshot file when V8's heap usage approaches its limit. This gives you a snapshot to analyze with Chrome DevTools before the OOM crash happens -- useful for tracking down memory leaks in long-running processes.