Support Node.js 10 (#497)

* Support node 10

* remove arrow function
This commit is contained in:
acappella2017 2019-08-27 20:10:45 +08:00 committed by James Sumners
parent 0eca4b6dd0
commit a8b09f3f81
1 changed files with 8 additions and 4 deletions

View File

@ -1114,6 +1114,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;
@ -1150,10 +1156,8 @@ 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');
// cleanup the listeners we attached in setup phrase.
socket.emit('cleanupSetupListeners');
// Work around lack of close event on tls.socket in node < 0.11
((socket.socket) ? socket.socket : socket).once('close',