Share this article Return
The new improvements and features of this release create the best workflow for Node.js developers to date. Highlighted updates and features include adding Node.js API for native module developers, Async_hooks, JS bindings for the inspector, zero-filling Buffers, util.promisify and more.
"Those who need stability and have complex production environments (i.e. medium and large enterprises) should wait until Node.js 8 goes into LTS before upgrading it for production."
Now, we'll go through the most important features and improvements of the new Node.js 8 release.
1. Async Hooks API:
The Async Hooks (formerly known as AsyncWrap) API has got a notable upgrade to the latest version. This API allows you to get structural tracing information about the life of handle objects.
The API emits events that inform the consumer about the life of all handle objects in Node.js. It tries to solve similar challenges as the continuation-local-storage npm package, just in the core.
Formerly, a package called ‘co’ was used to utilize generators to write better asynchronous code to create a more readable control flow. Now, this control flow can be implemented without the need of a third-party library.
2. The Advantage of Having N-API
util.promisify() allows developers to wrap callback APIs to return Promises. The function works with little overhead and follows a standard API.
- JS Bindings for the Inspector
3. Buffer security improvements in Node 8
There are two numbers, the first the zero filling Buffer and the second is a new Buffer. Both are added by default. However, earlier, the memory space was not initialized with zero because of which one had to face security issues as the Buffer instance had sensitive information.
The upgrading of the new version has enabled people to secure their privacy. However, it is advisable for the Node.js 8 users to first be aware of the risks factor involved in function and only then use to avoid the leakage of secure information. Though, there is an also a problem that you have to take performance hits. But it is better to move on to buffer.allocUnsafe ().
4. Upgrade V8 to 5.8: Preparing for TurboFan & Ingnition
The biggest change it brings to Node.js users is that it will make possible the introduction of TurboFan and Ignition in V8 5.9.Ignition is V8's interpreter, while TurboFan is the optimizing compiler.
Currently (well, with V8 versions older than 5.6, so anything below Node.js version 8) this is how the V8 compilation pipeline looks
The biggest issue with this pipeline is that new language features must be implemented in different parts of the pipeline, adding a lot of extra development work.
Simplified pipeline looks, without the FullCode Generator :
Photo credit: Benedikt Meurer
Other notable Addition in Node.js Version 8
- Buffer methods now accept Uint8Array as input
- Argument and kill signal validations have been improved
- Methods accept Uint8Array as input
- Error events emitted when using console methods are now suppressed
- Native Promise instances are now Domain aware
- Node has started assigning static error codes to errors generated
- The utility class fs.SyncWriteStream has been deprecated
- The deprecated fs.read() string interface has been removed
- Improved support for userland implemented Agents
- Outgoing Cookie headers are concatenated into a single string
- The httpResponse.writeHeader() method has been deprecated
- New methods for accessing HTTP headers have been added to OutgoingMessage
- The legacy linkedlist module has been removed.
- REPL magic mode has been removed
- The —-debug command-line argument has been removed
- Stream now supports destroy() and _destroy() APIs
- Stream now supports the final() API
- The rejectUnauthorized option now defaults to true
- Symbol keys are now displayed by default when using util.inspect()
- toJSON errors will be thrown when formatting %j
- Convert inspect.styles and inspect.colors to prototype-less objects
- Support Uint8Array in Zlib convenience methods
- Zlib errors now use RangeErrorand TypeError consistently
- The WHATWG URL implementation is now a fully-supports Node.js API
Node.js version 8 surprises us with a lot of interesting improvements, including the Async Hooks API which is hard to grasp with the current (but ever evolving) state of its documentation. Node.js is proud to associate with world renowned companies including Microsoft, Yahoo, Netflix, LinkedIn etc as its esteemed clients.
Those were some of the best features that come with NodeJS latest version which will assist in fulfilling various Single Page Application Development . Node.js just released it's latest update v8.1.1, and we will get back to you with more detailed explanations of these features soon.
Also refer Comparison Between: AngularJS Vs Node JS