-
-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"drain" event listener leak when unpiping to response #135
Comments
there is also a leak caused by mapping ServerResponse.once to ServerResponse.on so there is no easy way to wait for 'drain' events to happen by just using the |
If anyone came here looking for a workaround for the ability to call This is a bit of a mess, but you can do something like this: let onDrain;
// add a single drain listener early on
res.on('drain', () => {
if (onDrain) {
// call the onDrain callback at most once
onDrain();
onDrain = undefined;
}
});
// later, when you would normally call res.once('drain', ...)
onDrain = () => {
// resume your input stream or whatever
}; I hope that helps someone feeling stuck on this old issue. |
This is sort of a weird scenario, but this test case fails:
I hit this in some code that retries creating a read stream until the source exists. We clean up from our side:
rs.on("error", e => { rs.unpipe("res"); })
. Seems likecompression
needs to be cleaning up its listeners when"unpipe"
happens.The text was updated successfully, but these errors were encountered: