Skip to content

Commit e173397

Browse files
authored
Merge pull request #401 from tomas/remove-on-socket-end
Remove on_socket_end callback
2 parents 8353cdb + f92aee8 commit e173397

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

lib/needle.js

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -575,15 +575,6 @@ Needle.prototype.send_request = function(count, method, uri, config, post_data,
575575
}, milisecs);
576576
}
577577

578-
// handle errors on the underlying socket, that may be closed while writing
579-
// for an example case, see test/long_string_spec.js. we make sure this
580-
// scenario ocurred by verifying the socket's writable & destroyed states.
581-
function on_socket_end() {
582-
if (returned && !this.writable && this.destroyed === false) {
583-
this.destroy();
584-
had_error(new Error('Remote end closed socket abruptly.'))
585-
}
586-
}
587578

588579
debug('Making request #' + count, request_opts);
589580
request = protocol.request(request_opts, function(resp) {
@@ -833,7 +824,7 @@ Needle.prototype.send_request = function(count, method, uri, config, post_data,
833824
if (timer) clearTimeout(timer);
834825
})
835826

836-
// handle socket 'end' event to ensure we don't get delayed EPIPE errors.
827+
// set response timeout once we get a valid socket
837828
request.once('socket', function(socket) {
838829
if (socket.connecting) {
839830
socket.once('connect', function() {
@@ -842,15 +833,6 @@ Needle.prototype.send_request = function(count, method, uri, config, post_data,
842833
} else {
843834
set_timeout('response', config.response_timeout);
844835
}
845-
846-
// socket.once('close', function(e) {
847-
// console.log('socket closed!', e);
848-
// })
849-
850-
if (!socket.on_socket_end) {
851-
socket.on_socket_end = on_socket_end;
852-
socket.once('end', function() { process.nextTick(on_socket_end.bind(socket)) });
853-
}
854836
})
855837

856838
if (post_data) {

0 commit comments

Comments
 (0)