Skip to content

Commit

Permalink
on_socket_end: Ensure we don't destroy sockets only when necessary (#312
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tomas committed May 19, 2020
1 parent 0da0890 commit b15cb7a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/needle.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ Needle.prototype.send_request = function(count, method, uri, config, post_data,
// for an example case, see test/long_string_spec.js. we make sure this
// scenario ocurred by verifying the socket's writable & destroyed states.
function on_socket_end() {
if (!this.writable && this.destroyed === false) {
if (returned && !this.writable && this.destroyed === false) {
this.destroy();
had_error(new Error('Remote end closed socket abruptly.'))
}
Expand Down

0 comments on commit b15cb7a

Please sign in to comment.