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

ChangeStream should remove all event listeners on close

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

      When ChangeStream.prototype.close is called, we close the internal cursor but fail to remove event listeners from it. At best this is a memory leak, and at worst leads to difficult to trace bugs due to the closure still living on with an invalid reference to self. We should remove the events during close like so:

            ['data', 'close', 'end', 'error'].forEach(event =>
              this.cursor.removeAllListeners(event)
            );
      

            Assignee:
            rosemary.yin@mongodb.com Rosemary Yin (Inactive)
            Reporter:
            matt.broadstone@mongodb.com Matt Broadstone
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: