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

Remove mutation of user-owned objects

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.2.0
    • Affects Version/s: 3.0.2
    • Component/s: Native
    • Labels:
      None

      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.

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

              Created:
              Updated:
              Resolved: