Skip to content

Commit 236e98b

Browse files
authored
fix: end called when no connection has been established yet (#256)
1 parent 22e7cec commit 236e98b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

mysql/lib/client.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ export class AwsMySQLClient extends AwsClient {
211211
}
212212

213213
async end() {
214+
if (!this.isConnected || !this.targetClient?.client) {
215+
// No connections has been initialized.
216+
// This might happen if end is called in a finally block when an error occurred while initializing the first connection.
217+
return;
218+
}
219+
214220
const hostInfo: HostInfo | null = this.pluginService.getCurrentHostInfo();
215221
const result = await this.pluginManager.execute(
216222
this.pluginService.getCurrentHostInfo(),

pg/lib/client.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ export class AwsPGClient extends AwsClient {
192192
}
193193

194194
async end() {
195+
if (!this.isConnected || !this.targetClient?.client) {
196+
// No connections has been initialized.
197+
// This might happen if end is called in a finally block when an error occurred while initializing the first connection.
198+
return;
199+
}
195200
const hostInfo: HostInfo | null = this.pluginService.getCurrentHostInfo();
196201
const result = await this.pluginManager.execute(
197202
hostInfo,

0 commit comments

Comments
 (0)