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

Support Node.js 10 #497

Merged
merged 2 commits into from
Aug 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 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,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',
Expand Down