-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.2.4
-
Component/s: None
-
Empty show more show less
Right now when executing the Connection.close() method, it sometimes stays open and does not properly close all members of the socket pool.
We have a place in our code where we query a mongodb in a node script and quickly close the connection after a single query because it's not needed anymore. In our case something is staying open keeping the process running. When we utilize `process._getActiveHandles()` we can see that there are TLS sockets open to MongoDB.
The behavior consistently happens if we open a connection and immediately close. It happens infrequently if connect -> query -> close. I think it's likely because there is some boot race condition where the pool members are being initialized before they begin listening on the close event.
In our case we are connecting to a 3 member replset running Mongo Atlas. Here is a replication case with our url excluded.
const { MongoClient } = require("mongodb");const { MongoClient } = require("mongodb"); MongoClient.connect("URL", { poolSize : 10, ssl : true, domainsEnabled : true, connectTimeoutMS: 30000, socketTimeoutMS: 3600000, useNewUrlParser : true}, function(err, conn) { conn.close(function() { console.log("closed"); });});