From f081aa9f1fca15c55623c1691a20fea326e44d58 Mon Sep 17 00:00:00 2001 From: Ugo Bechameil Date: Tue, 10 Sep 2024 14:13:44 +0200 Subject: [PATCH] [HCK-7941] Connecting twice after listing databases was failing on opening the ssh tunnel (#116) * Connecting twice after listing databases was failing on opening the ssh tunnel twice * Make sure to not recreate ssh tunnel twice --- reverse_engineering/api.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reverse_engineering/api.js b/reverse_engineering/api.js index 772e313..7355a68 100644 --- a/reverse_engineering/api.js +++ b/reverse_engineering/api.js @@ -38,6 +38,7 @@ module.exports = { async getDatabases(connectionInfo, logger, cb, app) { const sshService = app.require('@hackolade/ssh-service'); + await postgresService.disconnect(sshService); try { logInfo('Get databases', connectionInfo, logger); @@ -78,7 +79,9 @@ module.exports = { }); postgresService.setDependencies(app); - await postgresService.connect(connectionInfo, sshService, postgresLogger); + if (!connectionInfo.ssh) { + await postgresService.connect(connectionInfo, sshService, postgresLogger); + } await postgresService.logVersion(); const schemasNames = await postgresService.getAllSchemasNames();