Node.js 14 Released with Diagnostic Reporting

Muthukumaraswamy
4 min readApr 24, 2020

--

The latest version of the JavaScript runtime Node.js. Node.js 14 Officially relased April 21, 2020 will replace Node.js 13 on the current release line where it will remain the ‘Current’ release for the next 6 months until Long Term Support(LTS) support arrives in October 2020.

What is new in nodejs 14

Diagnostic Report goes Stable, V8 upgraded to V8 8.1,Experimental Async Local Storage API,Streams,Experimental Web Assembly System Interface, Removal of Experimental Modules Warning, New compiler and platform minimums, Call to action

Diagnostic Report

The diagnostic report that was added as an experimental feature in Node.js 12 has been included in this release in a stable version. It can be used to generate a report on demand or when certain events occur, and has information for diagnosing problems including crashes, slow performance, memory leaks, high CPU usage and unexpected errors.

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’);
nodereport.triggerReport();

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:

process.report.writeReport(‘./filename.json’);

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.

AsyncLocalStorage

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. The experimental Async Hooks API was introduced in earlier versions as part of this work. Working with Async Local Storage until now relied on npm modules, but the Node.js team decided it would make more sense to have an internal API.

V8 upgraded to V8 8.1

As always a new version of the V8 JavaScript engine brings performance tweaks and improvements as well as keeping Node.js up with the ongoing improvements in the language and runtime.

  • Optional Chaining — which allows accessing the value of a property located deep within a chain of connected objects without the need to expressly validate that each reference in the chain,
  • Nullish Coalescing — a logical operator returning its right-hand side operand when its left-hand side operand is null/undefined (and otherwise returning its left-hand side operand),
  • Intl.DisplayNames - providing the consistency of language, region, and script display names translations,
  • Intl.DateTimeFormat - calendar and numberingSystem options enabled.

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. As an example, http.OutgoingMessage is similar to stream.Writable and net.Socket behaves exactly like stream.Duplex. A notable change is that the `autoDestroy` option is now defaulted to true, making the stream always call `_destroy` after ending. While we don’t believe these SemVer major changes will affect most applications, as they only change edge cases, if you rely heavily on Streams it would be good to test while Node.js 14 is the current release so that it is ready for when Node.js 14 becomes Long Term Support(LTS) in October 2020.

Other New Changes

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.

Experimental Web Assembly System Interface: Changes to WASI have been made to help support certain use cases and simplify the native modules experience.

What is 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.

--

--