diff --git a/packages/api/src/proc/sshForwardProcess.js b/packages/api/src/proc/sshForwardProcess.js index ecc4fffdb..63e14bed1 100644 --- a/packages/api/src/proc/sshForwardProcess.js +++ b/packages/api/src/proc/sshForwardProcess.js @@ -3,7 +3,7 @@ const platformInfo = require('../utility/platformInfo'); const childProcessChecker = require('../utility/childProcessChecker'); const { handleProcessCommunication } = require('../utility/processComm'); const { SSHConnection } = require('../utility/SSHConnection'); -const { getLogger, extractErrorLogData } = require('dbgate-tools'); +const { getLogger, extractErrorLogData, extractErrorMessage } = require('dbgate-tools'); const logger = getLogger('sshProcess'); @@ -46,7 +46,7 @@ async function handleStart({ connection, tunnelConfig }) { msgtype: 'error', connection, tunnelConfig, - errorMessage: err.message, + errorMessage: extractErrorMessage(err.message), }); } } diff --git a/packages/api/src/utility/sshTunnel.js b/packages/api/src/utility/sshTunnel.js index ff4f37af7..85d7fb8e3 100644 --- a/packages/api/src/utility/sshTunnel.js +++ b/packages/api/src/utility/sshTunnel.js @@ -50,7 +50,7 @@ function callForwardProcess(connection, tunnelConfig, tunnelCacheKey) { resolve(subprocess); } if (msgtype == 'error') { - reject(errorMessage); + reject(new Error(errorMessage)); } }); subprocess.on('exit', code => { @@ -91,6 +91,7 @@ async function getSshTunnel(connection) { }; return sshTunnelCache[tunnelCacheKey]; } catch (err) { + logger.error(extractErrorLogData(err), 'Error creating SSH tunnel:'); // error is not cached return { state: 'error', diff --git a/packages/tools/src/getConnectionLabel.ts b/packages/tools/src/getConnectionLabel.ts index 0c61f1eb2..6da1100b9 100644 --- a/packages/tools/src/getConnectionLabel.ts +++ b/packages/tools/src/getConnectionLabel.ts @@ -21,6 +21,9 @@ function getConnectionLabelCore(connection, { allowExplicitDatabase = true } = { if (connection.databaseFile) { return getDatabaseFileLabel(connection.databaseFile); } + if (connection.useSshTunnel && connection.server == 'localhost') { + return `${connection.sshHost} - SSH`; + } if (connection.server) { return connection.server; }