Skip to content

Commit 5b50864

Browse files
authored
chore(ssh-tunnel): add logging and improve displayed error message COMPASS-7336 (#4983)
1 parent d87a58e commit 5b50864

File tree

5 files changed

+150
-50
lines changed

5 files changed

+150
-50
lines changed

package-lock.json

Lines changed: 42 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-logging/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"reformat": "npm run prettier -- --write . && npm run eslint . --fix"
4949
},
5050
"dependencies": {
51-
"debug": "^4.2.0",
51+
"debug": "^4.3.4",
5252
"is-electron-renderer": "^2.0.1",
5353
"mongodb-log-writer": "^1.3.0"
5454
},
@@ -57,6 +57,7 @@
5757
"@mongodb-js/mocha-config-compass": "^1.3.1",
5858
"@mongodb-js/prettier-config-compass": "^1.0.1",
5959
"@mongodb-js/tsconfig-compass": "^1.0.3",
60+
"@types/debug": "^4.1.9",
6061
"@types/chai": "^4.2.21",
6162
"@types/mocha": "^9.0.0",
6263
"@types/sinon-chai": "^3.2.5",

packages/data-service/src/connect-mongo-client.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ export async function connectMongoClientDataService({
161161
connectionOptions.sshTunnel,
162162
logger
163163
);
164+
const tunnelForwardingErrors: Error[] = [];
165+
tunnel?.on('forwardingError', (err: Error) =>
166+
tunnelForwardingErrors.push(err)
167+
);
164168

165169
if (socks5Options) {
166170
Object.assign(options, socks5Options);
@@ -280,6 +284,13 @@ export async function connectMongoClientDataService({
280284
]).catch(() => {
281285
/* ignore errors */
282286
});
287+
if (tunnelForwardingErrors.length > 0) {
288+
err.message = `${
289+
err.message
290+
} [SSH Tunnel errors: ${tunnelForwardingErrors.map(
291+
(err) => err.message
292+
)}]`;
293+
}
283294
throw err;
284295
}
285296
}

packages/ssh-tunnel/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
"@mongodb-js/tsconfig-compass": "^1.0.3",
5656
"@types/chai": "^4.2.21",
5757
"@types/chai-as-promised": "^7.1.4",
58-
"@types/debug": "^4.1.7",
5958
"@types/mocha": "^9.0.0",
6059
"@types/node-fetch": "^2.5.8",
6160
"@types/sinon-chai": "^3.2.5",
@@ -74,7 +73,7 @@
7473
"typescript": "^5.0.4"
7574
},
7675
"dependencies": {
77-
"debug": "^4.2.0",
76+
"@mongodb-js/compass-logging": "^1.2.2",
7877
"socksv5": "0.0.6",
7978
"ssh2": "^1.12.0"
8079
}

0 commit comments

Comments
 (0)