Reputation: 59586
I have developed a node.js
application. Yet, at some stage, the application should shutdown naturally. I can see that it reaches the final instruction through a console.log()
message.
However, Netbeans tells me it is still running. There is something keeping the application alive, although I am end my connections to my database. I am running out of ideas.
How can I find out what is preventing my application from shutting down?
UPDATE
Here is the list of modules I use:
"dependencies": {
"async": "0.9",
"body-parser": "1.4.3",
"clean-css": "2.1.8",
"cookie": "0.1.2",
"cookie-parser": "1.1.0",
"crypto-js": "3.1.2-3",
"csurf": "1.2.0",
"emailjs": "0.3.6",
"express-session": "1.2.1",
"express": "4.3.1",
"html-minifier": "0.6.1",
"markup-js": "1.5.18",
"node-fs": "0.1.7",
"node-fs-extra": "0.8.1",
"pem": "1.4.1",
"pg": "3.2.0",
"readdirp": "1.0.1",
"st": "0.4.1",
"utils-merge": "1.0.0",
"validator": "3.12.0",
"yuicompressor": "2.4.8"
}
Upvotes: 2
Views: 525
Reputation: 106696
There are a couple of undocumented functions that can help you determine this somewhat: process._getActiveRequests()
and process._getActiveHandles()
. They both return an array of active requests (e.g. network requests) and active handles(/file descriptors) respectively.
In node v0.11+ there is a new (documented) API called AsyncListener which may also help you track asynchronous requests.
Upvotes: 2
Reputation: 211590
The most common problem I've found is that you have timeouts that have not executed. Since clearing those is not always practical, you may need to force quit your program with:
process.exit(0)
Upvotes: 0