Skip to content

Commit ab75c58

Browse files
committed
In order to fix problems with SNI initialization we basically had to re-create the logic
in init() which... didn't make a whole lot of sense. So this commit changes init() to be usable in the refresh case. Base use (with no args) will still behave as it did but on a refresh we should get a complete rebuild of expected state now.
1 parent e4f7d3d commit ab75c58

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

lib/control-connection.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ class ControlConnection extends events.EventEmitter {
176176
* Initializes the control connection by establishing a Connection using a suitable protocol
177177
* version to be used and retrieving cluster metadata.
178178
*/
179-
async init() {
180-
if (this.initialized) {
179+
async init(reinit) {
180+
if (this.initialized && !reinit) {
181181
// Prevent multiple serial initializations
182182
return;
183183
}
@@ -429,20 +429,10 @@ class ControlConnection extends events.EventEmitter {
429429
this.log("info", `Current host IDs: ${this.options.contactPoints}`);
430430
}
431431

432-
if (!this.options.sni) {
433-
434-
/* NODEJS-632: do fresh DNS lookups on contact points since some hostnames may have
435-
* shifted during the flight. */
436-
this.log("info", "Refreshing contact points");
437-
this._contactPoints.clear();
438-
this._resolvedContactPoints.clear();
439-
440-
await Promise.all(this.options.contactPoints.map(name => this._parseContactPoint(name)));
441-
const refreshedContactPoints = Array.from(this._contactPoints).join(',');
442-
this.log('info', `Refreshed contact points: ${refreshedContactPoints}`);
443-
}
444-
445-
await this._initializeConnection();
432+
this.log("info", "Re-initializing the control connection");
433+
this._contactPoints.clear();
434+
this._resolvedContactPoints.clear();
435+
await this.init(true)
446436
}
447437
}
448438

0 commit comments

Comments
 (0)