Skip to content

Commit

Permalink
fix(): do not initialize datasource if already initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
mo4islona committed Jun 8, 2022
1 parent 4566ab0 commit d359f4d
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 d359f4d

Please sign in to comment.