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

`checkServerIdentity: true` causes MongoClient to fail with callstack overflow

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

      Any connection string with ssl enabled and checkServerIdentity set to true seems to result in MongoClient.connect failed with callstack exceeded error:

      RangeError: Maximum call stack size exceeded
          at inspect (internal/util/inspect.js:285:15)
          at formatWithOptionsInternal (internal/util/inspect.js:2006:40)
          at formatWithOptions (internal/util/inspect.js:1888:10)
          at console.value (internal/console/constructor.js:313:14)
          at console.log (internal/console/constructor.js:348:61)
          at Topology.<anonymous> (/Users/sergey.petushkov/Projects/MongoDB/node-mongodb-native/lib/operations/connect.js:182:21)
          at Topology.emit (events.js:315:20)
          at Server.<anonymous> (/Users/sergey.petushkov/Projects/MongoDB/node-mongodb-native/lib/utils.js:574:73)
          at Server.emit (events.js:315:20)
          at ConnectionPool.<anonymous> (/Users/sergey.petushkov/Projects/MongoDB/node-mongodb-native/lib/utils.js:574:73)
      

      Even though driver allows to pass `checkServerIdentity` set to `true` it doesn't seem like a valid tls option for tls.connect.

      Looking at some internal driver events that happen before callstack overflows, seems like tls.connect validation failing can be the reason for the stack overflow. There are a bunch of following events happening before it breaks:

      ServerHeartbeatFailedEvent {
        connectionId: 'localhost:27020',
        duration: 2,
        failure: Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
        Please open an issue with this stack trace at https://github.com/nodejs/node/issues
        
            at assert (internal/assert.js:14:11)
            at Object.connect (_tls_wrap.js:1573:3)
            at makeConnection (/Users/sergey.petushkov/Projects/MongoDB/node-mongodb-native/lib/cmap/connect.js:234:35)
            at Object.connect (/Users/sergey.petushkov/Projects/MongoDB/node-mongodb-native/lib/cmap/connect.js:14:5)
            at checkServer (/Users/sergey.petushkov/Projects/MongoDB/node-mongodb-native/lib/sdam/monitor.js:186:15)
            at /Users/sergey.petushkov/Projects/MongoDB/node-mongodb-native/lib/sdam/monitor.js:218:9
            at executeAndReschedule (/Users/sergey.petushkov/Projects/MongoDB/node-mongodb-native/lib/utils.js:830:9)
            at Object.makeInterruptibleAsyncInterval (/Users/sergey.petushkov/Projects/MongoDB/node-mongodb-native/lib/utils.js:837:9)
            at Monitor.connect (/Users/sergey.petushkov/Projects/MongoDB/node-mongodb-native/lib/sdam/monitor.js:80:36)
            at Server.connect (/Users/sergey.petushkov/Projects/MongoDB/node-mongodb-native/lib/sdam/server.js:111:24) {
          code: 'ERR_INTERNAL_ASSERTION'
        }
      }
      

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            sergey.petushkov@mongodb.com Sergey Petushkov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: