Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit d702c45

Browse files
committed
Refactor the patch to limit its scope to bind actions
This way, other tests keep passing
1 parent 53d6b36 commit d702c45

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

lib/client/client.js

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ function Client (options) {
120120

121121
this.log = options.log.child({ clazz: 'Client' }, true)
122122

123-
this.on('error', function (err) {
124-
self.cb(err)
125-
})
126-
127123
this.timeout = parseInt((options.timeout || 0), 10)
128124
this.connectTimeout = parseInt((options.connectTimeout || 0), 10)
129125
this.idleTimeout = parseInt((options.idleTimeout || 0), 10)
@@ -172,18 +168,6 @@ function Client (options) {
172168
util.inherits(Client, EventEmitter)
173169
module.exports = Client
174170

175-
/**
176-
* Default handler for error callbacks when
177-
* one isn't set in the instance
178-
*/
179-
Client.prototype.cb = function (err, ret) {
180-
if (err) {
181-
this.log.error('Caught exception:', err)
182-
} else {
183-
this.log.info('Unhandled output:', ret)
184-
}
185-
}
186-
187171
/**
188172
* Sends an abandon request to the LDAP server.
189173
*
@@ -298,13 +282,15 @@ Client.prototype.bind = function bind (name,
298282
controls: controls
299283
})
300284

285+
// While we are binding to the server, register the callback as error handler
301286
var self = this
302-
this.cb = function (err, ret) {
303-
delete self.cb
287+
function callbackWrapper (err, ret) {
288+
self.removeListener('error', callbackWrapper)
304289
callback(err, ret)
305290
}
291+
this.addListener('error', callbackWrapper)
306292

307-
return this._send(req, [errors.LDAP_SUCCESS], null, callback, _bypass)
293+
return this._send(req, [errors.LDAP_SUCCESS], null, callbackWrapper, _bypass)
308294
}
309295

310296
/**

0 commit comments

Comments
 (0)