• Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.0
    • Affects Version/s: 3.2.0, 3.2.2, 3.2.3, 3.2.4, 3.2.5, 3.2.6, 3.2.7
    • Component/s: Core

      Hi,

      In file:
      https://github.com/mongodb-js/mongodb-core/blob/d40cb87ad415cfe224ae00d7696fc549fbbd0c62/lib/connection/msg.js#L105

       header.writeInt32LE(this.requestId, 4); // requestID
      

      requestId is used to write 2 bytes into header, but there is no limitation on how big this.requestId can be. It is growing with every message:

      https://github.com/mongodb-js/mongodb-core/blob/d40cb87ad415cfe224ae00d7696fc549fbbd0c62/lib/connection/msg.js#L133

      Msg.getRequestId = function() {
        return ++_requestId;
      };
      

      And so, eventually it will reach maximum allowed value +1 (I guess 32767+1).

      As node documentation is saying:

      https://nodejs.org/api/buffer.html#buffer_buf_writeint32le_value_offset

      value should be a valid signed 32-bit integer. Behavior is undefined when value is anything other than a signed 32-bit integer.

      In reality it means error which cannot be fixed even by re-connection to database:

      TypeError: "value" argument is out of bounds
      at checkInt (buffer.js:1185:11)
      at Buffer.writeInt32LE (buffer.js:1375:5)
      at Msg.toBin (/node_modules/mongodb/node_modules/mongodb-core/lib/connection/msg.js:105:12)
      

       

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

              Created:
              Updated:
              Resolved: