-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix event listener leak #2028
Fix event listener leak #2028
Conversation
When request handles a redirect, extra event listeners for the `pipe` and `end` events are erroneously attached to the request object. This fixes the leak by not attaching additional handlers if they're already there.
I'm just here to confirm that this issue is still not fixed, a simple way to test is to put this:
script on localhost and fetch with request it to see the annoying warning. |
Are there any plans to resolve this issue for good? We're seeing this memory leak as well and would appreciate the resolution. |
We're still waiting for this to be resolved. @mikeal @nylen @FredKSchott @simov? |
So is it time to merge this or what? :-) |
+1 waiting on this. |
+1 |
1 similar comment
👍 |
+1 |
Is anyone maintaining this repo anymore? |
This PR has been closed as "abandoned" as a part of an automated cleanup. If this is a mistake and you are still interested in merging this PR, please do the following:
Thank you for your understanding. If you have any questions, please check out #2556 and feel free to comment / ask anything there. |
@daguej would love to get this merged, sorry I'm only just seeing this now. In addition to the above, we'll also need a test to confirm this issue / confirm this fix / make sure it never regresses again. |
When request handles a redirect, extra event listeners for the
pipe
andend
events are erroneously attached to the request object. This causes a few problems:end
is fired, the cleanup function ends up running multiple times (1 + number of redirects). This doesn't actually hurt anything, but it is wasteful.pipe
event handler will run multiple times, thus emitting theerror
event multiple times.These warnings have been reported many, many times (#107, #281, #311, #585, #622, #673, #708,
#842, #870, #1497, #1809) but the underlying issue has never actually been properly resolved.
This fixes the leak for good by not attaching additional handlers if they're already there.
The diff makes it look like there are more changes than there actually are due to changes in indentation. The only actual change is to wrap the event listeners:
The small client & server I used to demonstrate this issue can be found here.