Skip to content

Commit

Permalink
Merge pull request #5136 from danielscw/fix/microservice-on-module-in…
Browse files Browse the repository at this point in the history
…it-error-handling

fix(microservice): handle promise return by 'registerModules' properly
  • Loading branch information
kamilmysliwiec authored Jul 29, 2020
2 parents 752033e + 63d0693 commit c420898
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/microservices/nest-microservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ export class NestMicroservice extends NestApplicationContext
}

public listen(callback: () => void) {
!this.isInitialized && this.registerModules();

this.logger.log(MESSAGES.MICROSERVICE_READY);
this.server.listen(callback);
this.listenAsync().then(callback);
}

public async listenAsync(): Promise<any> {
return new Promise(resolve => this.listen(resolve));
!this.isInitialized && (await this.registerModules());

this.logger.log(MESSAGES.MICROSERVICE_READY);
return new Promise(resolve => this.server.listen(resolve));
}

public async close(): Promise<any> {
Expand Down

0 comments on commit c420898

Please sign in to comment.