-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
support res.removeListener('drain'), res.once('drain') #153
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you! I'm just using this as a reminder for one of us (I can help when I have some time a bit later) make the tests actually not pass when the issue is there, as otherwise the CI state is not useful.
a75e2d2
to
7908367
Compare
Thanks for the fast turn-around. Fixed the issue you pointed out, and made it so tests actually fail. (Proxying |
Hi @zbjornson sorry; I didn't mean to make a new review, I was just still in the middle of reviewing and since the code changed underneath, github discarded all my in progress comments and i had to start a new review. i still need to retype a few of my comments, but need to leave the office right now, but will be back on later to finish retyping them 👍 |
p.s. (on mobile to write this) i just wanted to thank you for helping put this together. will get it out asap when it lands, as it's an important fix that i feel bad i never got around to fixing myself. pr is very appreciated |
Sorry for the force-push while you were reviewing! Meanwhile, I just pushed fixes for the comments so far.
Thanks! :) |
Yea, i think it would be nice to fix everything, but doesn't need to be in this pr if not desired. Was mostly just looking for (a) fix existing leak and (b) not introduce new leaks. If there are other leaks still, for instance, and they are not fixed, it's not a new one :) For example if removealllisteners is broken currently, this pr doesnt change that, so can be a separate fix, if desired. But the addlistener was just that it would have worked no leak and this would make it leak, which is why i brought it up, if that makes sense in my thought process |
9d85331
to
1aa646c
Compare
@dougwilson anything else you need from me on this PR? |
@dougwilson Sorry to bump this, but it looks like it's been forgotten about for a year now. We've been seeing memory leaks related to this in our production environment and would really love to see this merged in. Anything we can do to help get it in? |
We're experiencing this too. Reproducible like this const express = require('express');
const compression = require('compression');
const app = express();
const port = 8080;
// comment-out following line to make the problem disappear
app.use(compression());
// Some data to serve
const data = `long data long data long data long data\n`;
app.get('/', async (req, res) => {
res.set('content-type', 'text/plain; charset=utf-8');
for (let i = 0; i < 10000; i++) {
if (res.write(data)) continue;
await new Promise((resolve) => res.once('drain', resolve));
}
res.end();
});
app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`)); |
@dougwilson I think this PR is still ready to land. Despite the label, it has test coverage. |
Apologies for that (sitting and not updating the label). I will take a look tonight and ideally get it landed tonight for everyone. I also want to see it land :) but so many things go on sometimes loose track. |
I'm working on a change for this, as it seems to have the potential to break some other things that may be around, so just wanted to be careful around this. The idea for the original I'm working to fix that and will be pushing up a separate commit to the PR to address this, so be on the look out for it and check my work :) |
8256ec6
to
20d70d3
Compare
c2cdb03
to
dcba4b8
Compare
fa57c9f
to
c0daad2
Compare
Fixes #152
Fixes #135
This issue turned out not to be a duplicate of #135; unpiping still causes a leak.With latest changes, it is fixed