mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-22 09:01:09 +03:00
Ensure proper cleanup of the database connection in createSchema (#5315)
* Ensure proper cleanup of the database connection in `createSchema` method in `MySQLRecordManager`. * Update MySQLrecordManager.ts * Refactor createSchema to optimize dataSource usage Refactor createSchema method to avoid duplicate dataSource retrieval. * Refactor createSchema method for efficiency Refactor createSchema to avoid redundant dataSource retrieval. --------- Co-authored-by: Henry Heng <henryheng@flowiseai.com>
This commit is contained in:
@@ -205,8 +205,8 @@ class MySQLRecordManager implements RecordManagerInterface {
|
||||
}
|
||||
|
||||
async createSchema(): Promise<void> {
|
||||
const dataSource = await this.getDataSource()
|
||||
try {
|
||||
const dataSource = await this.getDataSource()
|
||||
const queryRunner = dataSource.createQueryRunner()
|
||||
const tableName = this.sanitizeTableName(this.tableName)
|
||||
|
||||
@@ -241,6 +241,8 @@ class MySQLRecordManager implements RecordManagerInterface {
|
||||
return
|
||||
}
|
||||
throw e
|
||||
} finally {
|
||||
await dataSource.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -222,8 +222,8 @@ class PostgresRecordManager implements RecordManagerInterface {
|
||||
}
|
||||
|
||||
async createSchema(): Promise<void> {
|
||||
const dataSource = await this.getDataSource()
|
||||
try {
|
||||
const dataSource = await this.getDataSource()
|
||||
const queryRunner = dataSource.createQueryRunner()
|
||||
const tableName = this.sanitizeTableName(this.tableName)
|
||||
|
||||
@@ -251,6 +251,8 @@ class PostgresRecordManager implements RecordManagerInterface {
|
||||
return
|
||||
}
|
||||
throw e
|
||||
} finally {
|
||||
await dataSource.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -179,8 +179,8 @@ class SQLiteRecordManager implements RecordManagerInterface {
|
||||
}
|
||||
|
||||
async createSchema(): Promise<void> {
|
||||
const dataSource = await this.getDataSource()
|
||||
try {
|
||||
const dataSource = await this.getDataSource()
|
||||
const queryRunner = dataSource.createQueryRunner()
|
||||
const tableName = this.sanitizeTableName(this.tableName)
|
||||
|
||||
@@ -208,6 +208,8 @@ CREATE INDEX IF NOT EXISTS group_id_index ON "${tableName}" (group_id);`)
|
||||
return
|
||||
}
|
||||
throw e
|
||||
} finally {
|
||||
await dataSource.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user