-
Notifications
You must be signed in to change notification settings - Fork 2
Description
In the notReadable state it's listening for either the end or read callback to finish, unfortunately if the read callback fires it doesn't clean up the end callback. And after 11 calls to next there are 10 event listeners for the end callback.
I know in my node version I get warned about possible memory leaks.
Suggestion
The existing logic here
await Promise.race([this._untilReadable(), this._untilEnd()]);Could possibly changed to this
const { promise: readPromise, cleanup: cleanRead } = this._untilReadable();
const { promise: endPromise, cleanup: cleanEnd } = this._untilEnd();
await Promise.race([readPromise, endPromise]);
cleanRead();
cleanEnd();The cleanUp callbacks will unhook any dangling event listeners
Metadata
Metadata
Assignees
Labels
No labels