-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
None
-
Affects Version/s: 2.2.30
-
Component/s: None
-
Environment:Mac OS X El Capitan, Node.js v4.8.0
I'm working on a feature which involves gracefully shutting down cluster worker processes in Node.js. Because of that, I'm closing servers, disconnecting from the database, etc.
Said project uses a database abstraction layer called Databank. Here's where Databank is directly calling the MongoDB driver: https://github.com/e14n/databank-mongodb/blob/bcddbdc38d9f335291575af6462558a3a79b27e6/lib/mongodb.js#L310
wtfnode reports the following after the app server and database connections have been shut down:
[WTF Node?] open handles: - File descriptors: (note: stdio always exists) - fd 1 (stdio) - fd 2 (stdio) - Sockets: - (?:?) -> localhost:? (destroyed) - Listeners: - connect: (anonymous) @ /Users/alex/Development/pump.io/node_modules/mongodb-core/lib/connection/connection.js:467 - Others: - Pipe
whereas without shutting down the database it showed this:
[WTF Node?] open handles: - File descriptors: (note: stdio always exists) - fd 1 (stdio) - fd 2 (stdio) - Sockets: - 127.0.0.1:51075 -> 127.0.0.1:27017 - Listeners: - connect: (anonymous) @ /Users/alex/Development/pump.io/node_modules/mongodb-core/lib/connection/connection.js:467 - Timers: - (7076617 ~ 1 hr) (anonymous) @ /Users/alex/Development/pump.io/node_modules/connect-databank/lib/connect-databank.js:295 - (5375501 ~ 1 hr) (anonymous) @ /Users/alex/Development/pump.io/lib/app.js:578 - (5000 ~ 5 s) (anonymous) @ /Users/alex/Development/pump.io/node_modules/mongodb-core/lib/topologies/server.js:230 - Intervals: - (60000 ~ 60 s) (anonymous) @ /Users/alex/Development/pump.io/node_modules/dialback-client/lib/dialbackclient.js:235 - (60000 ~ 60 s) (anonymous) @ /Users/alex/Development/pump.io/node_modules/dialback-client/lib/dialbackclient.js:235 - (60000 ~ 60 s) (anonymous) @ /Users/alex/Development/pump.io/node_modules/dialback-client/lib/dialbackclient.js:235 - (60000 ~ 60 s) (anonymous) @ /Users/alex/Development/pump.io/node_modules/dialback-client/lib/dialbackclient.js:235 - Others: - Pipe
So it's definitely doing something.
It appears from the stack trace that https://github.com/christkv/mongodb-core/blob/9fe2202ee94f65a30f213d0ad915f1852adcb123/lib/connection/connection.js#L467 is the leaky listener.
I see this in mongodb-core 2.1.14.