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

Commit de62615

Browse files
committed
fix(connection): ensure connection cleanup before fallback retry
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.
1 parent dbfe137 commit de62615

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/connection/connection.js

+7
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,13 @@ Connection.prototype.connect = function(_options) {
651651
);
652652
}
653653

654+
// clean up existing event handlers
655+
this.connection.removeAllListeners('error');
656+
this.connection.removeAllListeners('timeout');
657+
this.connection.removeAllListeners('close');
658+
this.connection.removeAllListeners('data');
659+
this.connection = undefined;
660+
654661
return doConnect(this, 4, _options, _errorHandler);
655662
});
656663
};

0 commit comments

Comments
 (0)