Skip to content

Commit

Permalink
Merge pull request #1300 from mo4islona/master
Browse files Browse the repository at this point in the history
Do not initialize datasource if already initialized
  • Loading branch information
kamilmysliwiec authored Jun 14, 2022
2 parents 3454481 + d359f4d commit 3a4c65c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/typeorm-core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class TypeOrmCoreModule implements OnApplicationShutdown {
const dataSource = await createTypeormDataSource(
options as DataSourceOptions,
);
return dataSource.initialize ? dataSource.initialize() : dataSource;
return dataSource.initialize && !dataSource.isInitialized ? dataSource.initialize() : dataSource;
}

let entities = options.entities;
Expand All @@ -233,7 +233,7 @@ export class TypeOrmCoreModule implements OnApplicationShutdown {
...options,
entities,
} as DataSourceOptions);
return dataSource.initialize ? dataSource.initialize() : dataSource;
return dataSource.initialize && !dataSource.isInitialized ? dataSource.initialize() : dataSource;
}).pipe(
handleRetry(
options.retryAttempts,
Expand Down

0 comments on commit 3a4c65c

Please sign in to comment.