Bugfix/Prevent open connections on typeorm datasource (#3652)

prevent open connections on typeorm datasource
This commit is contained in:
Henry Heng
2024-12-08 21:06:07 +00:00
committed by GitHub
parent 680fe8dee1
commit ddca80d4e0
7 changed files with 249 additions and 82 deletions
@@ -21,6 +21,13 @@ export class MySQLSaver extends BaseCheckpointSaver implements MemoryMethods {
private async getDataSource(): Promise<DataSource> {
const { datasourceOptions } = this.config
if (!datasourceOptions) {
throw new Error('No datasource options provided')
}
// Prevent using default Postgres port, otherwise will throw uncaught error and crashing the app
if (datasourceOptions.port === 5432) {
throw new Error('Invalid port number')
}
const dataSource = new DataSource(datasourceOptions)
await dataSource.initialize()
return dataSource