node.js, catching errors so script doesn't break?

后端 未结 2 673
逝去的感伤
逝去的感伤 2021-01-12 04:31

I have a node.js script and anytime an error happens node.js stops running with the error that happened.

What is the proper way of checking errors in node.js so it w

2条回答
  •  旧巷少年郎
    2021-01-12 05:07

    Catching uncaughtException is no longer recommended.

    Using domains are preferred. Using either "uncaughtException" or Domain, restarting the process is highly recommended after handling the exception.

    To auto-restart the process, NodeJS provides another library called Cluster which assists in managing the worker threads.

提交回复
热议问题