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

Consider stop using shallowClone all over the place

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • None

    Description

      Hello,

      This issue is about the native mongo driver for node.js
      It's not possible to open issues on the github repository, so I'm oppenning it here.
      I realized that you are shallow cloning the options passed to the connect method (and in some other random places).
      I think that is very unlikely that someone expects their options object to not be mutated. Usually I just provide the options object to the connect method and forget about it.
      My problem with shallow cloning is that I'm using getters on my options object, so I can defer certificates reading until it is needed , if it's even needed because there are many cases where not. This allows me to use the same object shape for both connections secured with SSL and connections that are not.
      But because you are shallow cloning the object you are accessing all the properties and hence execute all the getters.
      Here is my problematic line of the driver:
      https://github.com/mongodb/node-mongodb-native/blob/9dc5bbcc2235cf9a433345e2a9d9bf0ff72208dc/lib/authenticate.js#L76

      Regards

      Attachments

        Activity

          People

            Unassigned Unassigned
            danielo@caseonit.com Daniel Rodríguez
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: