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

Destroy MessageStream when connections are destroyed

    • 3
    • Not Needed
    • Not Needed

      Use Case

      As a Node Engineer
      I want to ensure that async resources are cleaned up
      So that I can prevent memory leaks.

      The Connection class does not destroy its message stream when cleaning itself up. This could lead to leaking memory, and can lead to bugs as the message stream can still produce values after the underlying raw socket has been closed.

      Unknowns

      • Should the Connection class null out the message stream during cleanup to allow for earlier gc?
        • No, not necessary.
      • Connection has a destroyed flag and a closed flag. Which one is the one that means the connection will be cleaned up?
        • (See Documentation Requirements)

      Acceptance Criteria

      Implementation Requirements

      • Ensure that MessageStream (kMessageStream) is destroyed whenever associated TCP socket(kStream) is destroyed/ended

      Testing Requirements

      • Add a unit test to check that Connections destroy both the socket and the MessageStream
      • Add test that checks that MessageStream cannot produce values after TCP socket is closed
      • If worth doing, add test that checks that the MessageStream no longer exists after destroying the socket

      Documentation Requirements

      • Document difference between closed and destroyed flags in the doc comments (The time at which they are set)

            Assignee:
            warren.james@mongodb.com Warren James
            Reporter:
            bailey.pearson@mongodb.com Bailey Pearson
            Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: