Skip to content

Commit

Permalink
Avoid duplicate emit when using a timeout
Browse files Browse the repository at this point in the history
When using a timeout and getting an error on the request, 2 errors were emitted.
  • Loading branch information
Marsup committed Sep 10, 2011
1 parent f551a2f commit 717789e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions main.js
Expand Up @@ -148,6 +148,7 @@ Request.prototype.request = function () {

var clientErrorHandler = function (error) {
if (setHost) delete self.headers.host
if (self.timeout && self.timeoutTimer) clearTimeout(self.timeoutTimer)
self.emit('error', error)
}
if (self.onResponse) self.on('error', function (e) {self.onResponse(e)})
Expand Down

0 comments on commit 717789e

Please sign in to comment.