Although Node.js 14 won’t be prompted to Long Term Support status until Oct. 2020, this release should be considered a must-have for many, especially given version 13 reaches end of life in June 2020.
Let’s take a look at some of the more exciting features for this new release.
The Diagnostic Report has officially been added as a stable feature for Node.js 14. For those that don’t know, Diagnostic Report provides user-consumable reports that contain information for debugging and triaging issues within a production environment. Diagnostic Report is capable of identifying almost all Node.js application anomalies in production, such as:
- Abnormal termination.
- Slow performance.
- Memory leaks.
- High CPU usage.
- Unexpected errors.
- Incorrect output.
Diagnostic Report was originally available as an npm module. In order to use the tool, users would have to install the module with the help of npm like so:
npm install node-report
Once installed, you could trigger a report, via an API call such as:
var nodereport = require('node-report');
With the release of Node.js, it is no longer necessary to install node-report, as the functionality is built into Node.js.
Now, a report can be generated from within you application in the form of:
You can also generate a report from the command line like so:
node --report-uncaught-exception --report-on-signal --report-on-fatalerror app.js
You can generate reports with other options, such as:
- –report-on-fatalerror triggers a report to be generated on fatal errors (such as out of memory).
- –report-compact generates reports in a single-line JSON format.
- –report-directory defines the location that will house the generated report.
- –report-filename name of the report to be generated.
- –report-signal sets the signal for report generation (such as SIGUSR2). This feature is not supported on Windows.
Experimental Async Local Storage API
Another feature that should have many a developer nodding in appreciation is the addition of the experimental AsyncLocalStorage API. This high-level API will make it easier for applications to reach stability as it exposes fewer internals.
AsyncLocalStorage is used to create asynchronous state within callbacks and promise chains, and allows storing data throughout the lifetime of a web request. AsyncLocalStorage is similar to thread-local storage in other languages.
Although you might find other npm modules provide a similar functionality, using those various packages in a comprehensive way was challenging. Because of this, it was decided an API should be provided.
Other New Changes
With the release of v14.0.0, there were some other changes developers should know about. For example:
- Internationalization support: Node.js 14 will be the first LTS release to include full ICU data by default.
- Easier module creation/building/support: Node.js 14 ships N-API version 6, which includes support for BigInt.
- Streams: Changes have been made to improve consistency across the Streams APIs. These changes will help remove ambiguity and streamline behaviors across the Node.js core.
- Experimental Web Assembly System Interface: Changes to WASI have been made to help support certain use cases and simplify the native modules experience.
Also note, the following have been deprecated:
- crypto: move pbkdf2 without digest to EOL.
- fs: deprecate closing FileHandle on garbage collection.
- http: move OutboundMessage.prototype.flush to EOL.
- lib: move GLOBAL and root aliases to EOL.
- os: move tmpDir() to EOL.
- src: remove deprecated wasm type check.
- stream: move _writableState.buffer to EOL.
- doc: deprecate process.mainModule.
- doc: deprecate process.umask() with no arguments.
- module: remove experimental modules warning.
New System Requirements
With the upgrade to Node.js 14, there are new compiler and platform minimums to make note of. For example, the minimum macOS target version is now 10.13 (High Sierra). For Linux, the minimum GCC level remains at 6, but the developers of Node.js are planning to build and release binaries for platforms using GCC 8. Finally Node.js 14 will not run on Windows releases that have reached end-of-life.