Commit 234fb122 authored by isaacs's avatar isaacs Committed by Fedor Indutny
Browse files

http client: Ensure socket cleanup on response end

If an http response has an 'end' handler that throws, then the socket
will never be released back into the pool.

Granted, we do NOT guarantee that throwing will never have adverse
effects on Node internal state.  Such a guarantee cannot be reasonably
made in a shared-global mutable-state side-effecty language like
JavaScript.  However, in this case, it's a rather trivial patch to
increase our resilience a little bit, so it seems like a win.

There is no semantic change in this case, except that some event
listeners are removed, and the `'free'` event is emitted on nextTick, so
that you can schedule another request which will re-use the same socket.
From the user's point of view, there should be no detectable difference.

Closes #5107
parent db8ce89f
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment