Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why is domain API deprecated in Node.js?

Tags:

Why is domain API deprecated in Node.js?

I found it handy to catch errors in context of a incoming web request rather than exception boiling up to the level of process.

Also, is there any alternative to domain APIs that can be now be used?

like image 614
prasun Avatar asked Nov 05 '15 18:11

prasun


People also ask

What is meant by deprecated in node JS?

js deprecation warning is that it points out that in future versions unhandled promise rejection will also lead to process termination. That's a really important piece of information. So, never forget to catch the errors! This logging aligns with Chrome, which shows a console message for not handled promise rejections.

Is require deprecated in node JS?

It is not deprecated.

Is Node JS good for API?

js is lightweight, fast and scalable. Node. js allows you to build fast, scalable API Proxy capable of handling a huge number of simultaneous requests with high throughput.

What is domain in node JS?

Node. js domain module is used to intercept unhandled error. These unhandled error can be intercepted using internal binding or external binding. If errors are not handled at all, then they will simply crash the Node application. Internal Binding − Error emitter is executing its code within the run method of a domain.


1 Answers

Node.js issue #66: deprecate domains:

The problem isn't the user experience of domains, as you say the API is simple and users are generally happy with it, but the consequences domains have in maintenance and complications for the node.js core code – that seemingly simple API impacts all of the code base in a too negative way.

Domains in its current form must go. That's certain. What the alternative is, no one knows.

I don't get how we can deprecate something that covers a use case that cannot be covered otherwise, without providing clear (and ready) alternatives.

If we flip that the other way around. We know domains must go, and will have to be removed at some point soon-ish. Would you prefer there be no indication of this?

The linked issue also mentions (the lack of) alternatives.

like image 82
ax. Avatar answered Oct 01 '22 18:10

ax.