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

Remove mutation of user-owned objects

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.0.2
    • Fix Version/s: 3.2.0
    • Component/s: native
    • Labels:

      Description

      Currently, we mutate some user-owned objects like queries and options. The biggest offender is https://github.com/mongodb/node-mongodb-native/blob/3.0.0/lib/utils.js#L386, where we add a session to the passed-in options object.

      This can lead to some problems and unintended side effects. For one, this will cause an error if the passed in object is frozen or sealed. Additionally, it can have unintended consequences if combined with Proxies and/or custom setters.

      Ideally, we should not mutate user-owned objects, while feeling free to mutate objects that we own (collections, topologies, etc.). The only reason we should elect to mutate would be if there are major performance considerations.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: