Skip to content

Commit

Permalink
Merge pull request #1269 from thomasconner/feat/typeorm-0.3-migration
Browse files Browse the repository at this point in the history
Check if datasource is initialized before destroying it
  • Loading branch information
kamilmysliwiec authored May 20, 2022
2 parents 3d3a3f1 + a5e84c1 commit 3b14f13
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 3b14f13

Please sign in to comment.