Golo Roden
Golo Roden

Reputation: 150624

Force process.exit() vs closing all open resources/sockets manually

Say, I have a Node.js application that connects to a web server. At some point in time, I need to end this application.

Now I have two options:

Of course, the first approach is much more brute-force, but it's also way less coding ;-).

Are there any disadvantages I should be aware of when doing it like this? In other words: Could this result in not-cleaned up resources, like still-open sockets (either on the client, or on the server)? Does this affect when the server cleans up its resources for this connection, or is this done immediately?

Upvotes: 2

Views: 787

Answers (1)

matteo
matteo

Reputation: 1715

I put myself the same question when trying to decide the best way to handle errors and I foud very useful the following:

  1. http://www.joyent.com/developers/node/design/errors

in particular the section "The best way to recover from programmer errors is to crash immediately".

Upvotes: 2

Related Questions