Skip to content

Commit

Permalink
fix: dataSource.destroy runs as synchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
jiho-kr committed Oct 16, 2022
1 parent 5cf388d commit ede8c9d
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 ede8c9d

Please sign in to comment.