Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-1971

Connections staying open after close is called.

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.2.7
    • Affects Version/s: 3.2.4
    • Component/s: None

      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"); });});
      

       

       

            Assignee:
            daniel.aprahamian@mongodb.com Daniel Aprahamian (Inactive)
            Reporter:
            owenallenaz Owen Allen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: