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

Commit 04dfc96

Browse files
committed
refactor(pool): move connect error debug logging to call site
We previously emitted a debug message when a connection failed in the `Connection.connect` method. Now that we have moved all initialization to a single method, it's more appropriate to move the debug message to the `connect` call site's error case.
1 parent f25683e commit 04dfc96

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/connection/pool.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ function attemptReconnect(self) {
385385
self.connectingConnections--;
386386

387387
if (err) {
388+
if (self.logger.isDebug()) {
389+
self.logger.debug(`connection attempt failed with error [${JSON.stringify(err)}]`);
390+
}
391+
388392
self.retriesLeft = self.retriesLeft - 1;
389393
if (self.retriesLeft <= 0) {
390394
self.destroy();
@@ -705,6 +709,10 @@ Pool.prototype.connect = function(credentials) {
705709
self.connectingConnections--;
706710

707711
if (err) {
712+
if (self.logger.isDebug()) {
713+
self.logger.debug(`connection attempt failed with error [${JSON.stringify(err)}]`);
714+
}
715+
708716
// NOTE: when `err` exists, `connection` is actually the originating event name
709717
connectionFailureHandler(self, connection, err);
710718
return;
@@ -1276,6 +1284,10 @@ function _createConnection(self) {
12761284
self.connectingConnections--;
12771285

12781286
if (err) {
1287+
if (self.logger.isDebug()) {
1288+
self.logger.debug(`connection attempt failed with error [${JSON.stringify(err)}]`);
1289+
}
1290+
12791291
if (!self.reconnectId && self.options.reconnect) {
12801292
self.reconnectId = setTimeout(attemptReconnect(self), self.options.reconnectInterval);
12811293
}

0 commit comments

Comments
 (0)