Skip to content

Commit 05dd5e5

Browse files
committed
add more logs
1 parent 85d9edd commit 05dd5e5

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

packages/compass-connections/src/stores/connections-store-redux.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,9 @@ const connectWithOptions = (
15211521
inflightConnection = (async () => {
15221522
const deviceAuthAbortController = new AbortController();
15231523

1524+
let cancelled = false;
1525+
let started = false;
1526+
let succeeded = false;
15241527
try {
15251528
if (
15261529
getCurrentConnectionStatus(getState(), connectionInfo.id) ===
@@ -1639,6 +1642,17 @@ const connectWithOptions = (
16391642
);
16401643
}
16411644

1645+
started = true;
1646+
log.info(
1647+
mongoLogId(1_001_000_005),
1648+
'Compass Connection Attempt Started',
1649+
'Connection attempt started',
1650+
{
1651+
clusterName: connectionInfo.atlasMetadata?.clusterName,
1652+
connectionId: connectionInfo.id,
1653+
}
1654+
);
1655+
16421656
const connectionAttempt = createConnectionAttempt({
16431657
logger: log.unbound,
16441658
proxyOptions: proxyPreferenceToProxyOptions(
@@ -1659,6 +1673,16 @@ const connectWithOptions = (
16591673
// This is how connection attempt indicates that the connection was
16601674
// aborted
16611675
if (!dataService || connectionAttempt.isClosed()) {
1676+
cancelled = true;
1677+
log.info(
1678+
mongoLogId(1_001_000_007),
1679+
'Compass Connection Attempt Cancelled',
1680+
'Connection attempt cancelled',
1681+
{
1682+
clusterName: connectionInfo.atlasMetadata?.clusterName,
1683+
connectionId: connectionInfo.id,
1684+
}
1685+
);
16621686
dispatch({
16631687
type: ActionTypes.ConnectionAttemptCancelled,
16641688
connectionId: connectionInfo.id,
@@ -1825,6 +1849,7 @@ const connectWithOptions = (
18251849
connectionInfo
18261850
);
18271851

1852+
succeeded = true;
18281853
log.info(
18291854
mongoLogId(1_001_000_006),
18301855
'Compass Connection Attempt Succeeded',
@@ -1870,6 +1895,18 @@ const connectWithOptions = (
18701895
);
18711896
}
18721897
} catch (err) {
1898+
if (started && !succeeded && !cancelled) {
1899+
log.info(
1900+
mongoLogId(1_001_000_008),
1901+
'Compass Connection Attempt Failed',
1902+
'Connection attempt failed',
1903+
{
1904+
clusterName: connectionInfo.atlasMetadata?.clusterName,
1905+
connectionId: connectionInfo.id,
1906+
error: (err as Error).message,
1907+
}
1908+
);
1909+
}
18731910
dispatch(connectionAttemptError(connectionInfo, err));
18741911
} finally {
18751912
deviceAuthAbortController.abort();

0 commit comments

Comments
 (0)