How to use the `domain` module in Node.js correctly

What is the correct way to use the domain module in NodeJS applications?

  • Complete the code blocks with the domain instance, for example, how do we use try-catch blocks? If so, do I need to create new domain instances for each individual block each time?
  • Connect the main function using the run domain method If so, is this really enough for an enterprise application?

PS Is there any well-known open source project node with extensive use of the domain module where I can learn their code?

PPS Looking at the node documentation and tutorials, I see that almost all of them just simply complete the main function in the run domain method, however, as far as I can see, they basically copy each other. Basically, I don’t see how people use the domain module in different situations (I see, basically, a copy of the node documentation with a few minor changes)

+4
source share

Source: https://habr.com/ru/post/1493277/


All Articles