I have added a paragraph addressing this:

Several people commented that domain module is deprecated and it should not be used.

Image for post
Image for post
Deprecation notice.

Despite the big red banner stating that this module is deprecated — domain module is not deprecated. If you read the paragraph following the banner, it states that the module is pending deprecation once a replacement API is finalised. It is likely that async_hooks will eventually provide all functionality provided by domain module and will supersede it. Behind the scenes domain module is already implemented using async_hooks. However, it is not happening any time soon (because loads of popular NPM modules and Node.js internals depend on domain module) and until that time it safe to use domain module.

The preference for using domain module over cls_hooks or async_hooks is simply because they provide a friendlier API (for this purpose).

Written by

Software architect, startup adviser. Editor of https://medium.com/applaudience. Founder of https://go2cinema.com.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store