Skip to content

Commit

Permalink
chore(ssh-tunnel): add logging and improve displayed error message CO…
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax authored Oct 13, 2023
1 parent d87a58e commit 5b50864
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 50 deletions.
60 changes: 42 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/compass-logging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"reformat": "npm run prettier -- --write . && npm run eslint . --fix"
},
"dependencies": {
"debug": "^4.2.0",
"debug": "^4.3.4",
"is-electron-renderer": "^2.0.1",
"mongodb-log-writer": "^1.3.0"
},
Expand All @@ -57,6 +57,7 @@
"@mongodb-js/mocha-config-compass": "^1.3.1",
"@mongodb-js/prettier-config-compass": "^1.0.1",
"@mongodb-js/tsconfig-compass": "^1.0.3",
"@types/debug": "^4.1.9",
"@types/chai": "^4.2.21",
"@types/mocha": "^9.0.0",
"@types/sinon-chai": "^3.2.5",
Expand Down
11 changes: 11 additions & 0 deletions packages/data-service/src/connect-mongo-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ export async function connectMongoClientDataService({
connectionOptions.sshTunnel,
logger
);
const tunnelForwardingErrors: Error[] = [];
tunnel?.on('forwardingError', (err: Error) =>
tunnelForwardingErrors.push(err)
);

if (socks5Options) {
Object.assign(options, socks5Options);
Expand Down Expand Up @@ -280,6 +284,13 @@ export async function connectMongoClientDataService({
]).catch(() => {
/* ignore errors */
});
if (tunnelForwardingErrors.length > 0) {
err.message = `${
err.message
} [SSH Tunnel errors: ${tunnelForwardingErrors.map(
(err) => err.message
)}]`;
}
throw err;
}
}
3 changes: 1 addition & 2 deletions packages/ssh-tunnel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"@mongodb-js/tsconfig-compass": "^1.0.3",
"@types/chai": "^4.2.21",
"@types/chai-as-promised": "^7.1.4",
"@types/debug": "^4.1.7",
"@types/mocha": "^9.0.0",
"@types/node-fetch": "^2.5.8",
"@types/sinon-chai": "^3.2.5",
Expand All @@ -74,7 +73,7 @@
"typescript": "^5.0.4"
},
"dependencies": {
"debug": "^4.2.0",
"@mongodb-js/compass-logging": "^1.2.2",
"socksv5": "0.0.6",
"ssh2": "^1.12.0"
}
Expand Down
Loading

0 comments on commit 5b50864

Please sign in to comment.