From f92aee88d95c669197cc5ae5407174def54d8523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Pollak?= Date: Thu, 7 Apr 2022 10:43:19 -0400 Subject: [PATCH] Remove on_socket_end callback, looks like we don't need it anymore --- lib/needle.js | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/lib/needle.js b/lib/needle.js index a8a1627f7..cfae245ce 100644 --- a/lib/needle.js +++ b/lib/needle.js @@ -575,15 +575,6 @@ Needle.prototype.send_request = function(count, method, uri, config, post_data, }, milisecs); } - // handle errors on the underlying socket, that may be closed while writing - // 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 (returned && !this.writable && this.destroyed === false) { - this.destroy(); - had_error(new Error('Remote end closed socket abruptly.')) - } - } debug('Making request #' + count, request_opts); request = protocol.request(request_opts, function(resp) { @@ -833,7 +824,7 @@ Needle.prototype.send_request = function(count, method, uri, config, post_data, if (timer) clearTimeout(timer); }) - // handle socket 'end' event to ensure we don't get delayed EPIPE errors. + // set response timeout once we get a valid socket request.once('socket', function(socket) { if (socket.connecting) { socket.once('connect', function() { @@ -842,15 +833,6 @@ Needle.prototype.send_request = function(count, method, uri, config, post_data, } else { set_timeout('response', config.response_timeout); } - - // socket.once('close', function(e) { - // console.log('socket closed!', e); - // }) - - if (!socket.on_socket_end) { - socket.on_socket_end = on_socket_end; - socket.once('end', function() { process.nextTick(on_socket_end.bind(socket)) }); - } }) if (post_data) {