Skip to content

Commit 71dbf56

Browse files
committed
chore: fix linter issues and some status mismatch
1 parent a6efc47 commit 71dbf56

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/tools/atlas/connect/connectCluster.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ export class ConnectClusterTool extends AtlasToolBase {
3535
}
3636

3737
const currentConectionState = this.session.connectionManager.currentConnectionState;
38+
if (
39+
this.session.connectedAtlasCluster.projectId !== projectId ||
40+
this.session.connectedAtlasCluster.clusterName !== clusterName
41+
) {
42+
return "connected-to-other-cluster";
43+
}
44+
3845
switch (currentConectionState.tag) {
39-
case "connected":
40-
if (
41-
this.session.connectedAtlasCluster.projectId !== projectId ||
42-
this.session.connectedAtlasCluster.clusterName !== clusterName
43-
) {
44-
return "connected-to-other-cluster";
45-
} else {
46-
return "connected";
47-
}
4846
case "connecting":
4947
case "disconnected": // we might still be calling Atlas APIs and not attempted yet to connect to MongoDB, but we are still "connecting"
5048
return "connecting";
49+
case "connected":
50+
return "connected";
5151
case "errored":
5252
logger.debug(
5353
LogId.atlasConnectFailure,
@@ -218,10 +218,9 @@ export class ConnectClusterTool extends AtlasToolBase {
218218
break;
219219
}
220220
case "connected-to-other-cluster":
221-
await this.session.disconnect();
222-
// eslint-disable-next-line no-fallthrough
223221
case "disconnected":
224222
default: {
223+
await this.session.disconnect();
225224
const { connectionString, atlas } = await this.prepareClusterConnection(projectId, clusterName);
226225

227226
// try to connect for about 5 minutes asynchronously

0 commit comments

Comments
 (0)