Skip to content

Commit f336341

Browse files
committed
Added additional logging of retry connection on ssl error
1 parent edbc025 commit f336341

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

reverse_engineering/helpers/connectionHelper.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,26 @@ const createClient = async (connectionInfo, logger) => {
123123
application_name: 'Hackolade',
124124
};
125125

126-
const client = await connectClient(config).catch(retryOnSslError(connectionInfo, config));
126+
const client = await connectClient(config).catch(retryOnSslError(connectionInfo, config, logger));
127127

128128
return { client, sshTunnel };
129129
};
130130

131-
const retryOnSslError = (connectionInfo, config) => async error => {
131+
const retryOnSslError = (connectionInfo, config, logger) => async error => {
132132
if (error.message === SSL_NOT_SUPPORTED_MESSAGE && connectionInfo.sslType === 'prefer') {
133+
logger.info("Retry connection without SSL (SSL mode 'prefer')");
134+
logger.error(error);
135+
133136
return await connectClient({
134137
...config,
135138
ssl: false,
136139
});
137140
}
138141

139-
if (error.code === POSTGRES_SSL_REQUIRED_ERROR_CODE && connectionInfo.sslType === 'allow') {
142+
if (error.code?.toString() === POSTGRES_SSL_REQUIRED_ERROR_CODE && connectionInfo.sslType === 'allow') {
143+
logger.info("Retry connection with SSL (SSL mode 'allow')");
144+
logger.error(error);
145+
140146
return await connectClient({
141147
...config,
142148
ssl: { rejectUnauthorized: false },

0 commit comments

Comments
 (0)