Skip to content

Commit

Permalink
Merge pull request #1 from jiho-kr/destory-synchronous
Browse files Browse the repository at this point in the history
fix: `dataSource.destroy` runs as synchronously
  • Loading branch information
kibae authored Oct 16, 2022
2 parents 5cf388d + ede8c9d commit 7313c02
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/sharding-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ export class ShardingManager {

async destroy() {
this._destroyed = true;
await Promise.all(
this.dataSources.map((dataSource) => {
dataSource.destroy();
})
);
await Promise.all(this.dataSources.map((dataSource) => dataSource.destroy()));
}
}
5 changes: 4 additions & 1 deletion src/test/repository-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ describe('Repository Service', () => {
});

afterEach(async () => {
dataSource?.destroy();
if (dataSource) {
await dataSource.destroy();
dataSource.dataSources.forEach((dataSource) => expect(dataSource.isInitialized).toEqual(false));
}
});

it('Case1 - insert into last shard', async () => {
Expand Down
5 changes: 4 additions & 1 deletion src/test/sharding-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ describe('ShardingManager', () => {
});

afterEach(async () => {
dataSource?.destroy();
if (dataSource) {
await dataSource.destroy();
dataSource.dataSources.forEach((dataSource) => expect(dataSource.isInitialized).toEqual(false));
}
});

it('DataSource', async () => {
Expand Down

0 comments on commit 7313c02

Please sign in to comment.