Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
fix(connection): ensure connection cleanup before fallback retry
Browse files Browse the repository at this point in the history
Now that we default to connecting to ipv6 hosts first, and then
fallback to ipv4, we need to make sure that there are no duplicate
event handlers attached to the connection which might cause
confusion up the chain.
  • Loading branch information
mbroadst committed Dec 23, 2017
1 parent dbfe137 commit de62615
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/connection/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,13 @@ Connection.prototype.connect = function(_options) {
);
}

// clean up existing event handlers
this.connection.removeAllListeners('error');
this.connection.removeAllListeners('timeout');
this.connection.removeAllListeners('close');
this.connection.removeAllListeners('data');
this.connection = undefined;

return doConnect(this, 4, _options, _errorHandler);
});
};
Expand Down

0 comments on commit de62615

Please sign in to comment.