Skip to content

Commit

Permalink
Handle socket.destroy correctly when redirecting on Node versions >= …
Browse files Browse the repository at this point in the history
…8.12.0
  • Loading branch information
tomas committed Sep 20, 2018
1 parent 2ca2136 commit 942b3e4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/needle.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,9 @@ 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) {
// socket.ssl is present on node versions 8.12.0, where the socket.destroy
// logic was apparently fixed.
if (!this.writable && this.destroyed === false && !this.ssl) {
this.destroy();
had_error(new Error('Remote end closed socket abruptly.'))
}
Expand Down

0 comments on commit 942b3e4

Please sign in to comment.