Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove connectionErrorHandler to fix #1903 #2240

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 0 additions & 24 deletions request.js
Expand Up @@ -71,20 +71,6 @@ function filterOutReservedFunctions(reserved, options) {

}

// Function for properly handling a connection error
function connectionErrorHandler(error) {
var socket = this
if (socket.res) {
if (socket.res.request) {
socket.res.request.emit('error', error)
} else {
socket.res.emit('error', error)
}
} else {
socket._httpMessage.emit('error', error)
}
}

// Return a simpler request object to allow serialization
function requestToJSON() {
var self = this
Expand Down Expand Up @@ -805,11 +791,6 @@ Request.prototype.start = function () {
self.emit('socket', socket)
})

self.on('end', function() {
if ( self.req.connection ) {
self.req.connection.removeListener('error', connectionErrorHandler)
}
})
self.emit('request', self.req)
}

Expand Down Expand Up @@ -844,11 +825,6 @@ Request.prototype.onRequestResponse = function (response) {
debug('response end', self.uri.href, response.statusCode, response.headers)
})

// The check on response.connection is a workaround for browserify.
if (response.connection && response.connection.listeners('error').indexOf(connectionErrorHandler) === -1) {
response.connection.setMaxListeners(0)
response.connection.once('error', connectionErrorHandler)
}
if (self._aborted) {
debug('aborted', self.uri.href)
response.resume()
Expand Down