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?
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.
It is not deprecated.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With