Skip to content

Commit

Permalink
fix: end called when no connection has been established yet (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
karenc-bq authored Oct 22, 2024
1 parent 22e7cec commit 236e98b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mysql/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ export class AwsMySQLClient extends AwsClient {
}

async end() {
if (!this.isConnected || !this.targetClient?.client) {
// No connections has been initialized.
// This might happen if end is called in a finally block when an error occurred while initializing the first connection.
return;
}

const hostInfo: HostInfo | null = this.pluginService.getCurrentHostInfo();
const result = await this.pluginManager.execute(
this.pluginService.getCurrentHostInfo(),
Expand Down
5 changes: 5 additions & 0 deletions pg/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ export class AwsPGClient extends AwsClient {
}

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

0 comments on commit 236e98b

Please sign in to comment.