Skip to content

Commit

Permalink
Support Node.js 10 ldapjs#497
Browse files Browse the repository at this point in the history
  • Loading branch information
kspearrin committed Mar 22, 2019
1 parent 5eab28e commit 12c07b1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,12 @@ Client.prototype.connect = function connect() {
socket.once('error', bail);
socket.once('end', bail);
socket.once('timeout', bail);
socket.once('cleanupSetupListeners', function onCleanup() {
socket.removeListener('error', bail)
.removeListener('close', bail)
.removeListener('end', bail)
.removeListener('timeout', bail);
});

self._socket = socket;
self._tracker = tracker;
Expand Down Expand Up @@ -1147,10 +1153,7 @@ Client.prototype.connect = function connect() {

// Wire up "official" event handlers after successful connect/setup
function postSetup() {
socket.removeAllListeners('error')
.removeAllListeners('close')
.removeAllListeners('end')
.removeAllListeners('timeout');
socket.emit('cleanupSetupListeners');

// Work around lack of close event on tls.socket in node < 0.11
((socket.socket) ? socket.socket : socket).once('close',
Expand Down Expand Up @@ -1452,7 +1455,7 @@ Client.prototype._sendSocket = function _sendSocket(message,
conn.removeAllListeners('error');
conn.on('error', function () {});
conn.end();
return callback(null);
// return callback(null);
} else if (emitter) {
sentEmitter = true;
return callback(null, emitter);
Expand Down

0 comments on commit 12c07b1

Please sign in to comment.