ChangeStream should remove all event listeners on close

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • next
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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 (Inactive)
              Reporter:
              Matt Broadstone
              None
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: