-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Connection Layer
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)