Skip to content

Commit

Permalink
fix: check if the dataSource is initialized before destroying it
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasconner committed May 11, 2022
1 parent 3d3a3f1 commit a5e84c1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/typeorm-core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ export class TypeOrmCoreModule implements OnApplicationShutdown {
getDataSourceToken(this.options as DataSourceOptions) as Type<DataSource>,
);
try {
dataSource && (await dataSource.destroy());
if (dataSource && dataSource.isInitialized) {
await dataSource.destroy();
}
} catch (e) {
this.logger.error(e?.message);
}
Expand Down

0 comments on commit a5e84c1

Please sign in to comment.