Skip to content

Commit

Permalink
refactor(core): replace internal init with an inline promise
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Nov 15, 2024
1 parent dade6d5 commit e64ab18
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/core/nest-application-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,15 @@ export class NestApplicationContext<
if (this.isInitialized) {
return this;
}
this.initializationPromise = this.internalInit();
this.initializationPromise = new Promise(async (resolve, reject) => {
try {
await this.callInitHook();
await this.callBootstrapHook();
resolve();
} catch (err) {
reject(err);
}
});
await this.initializationPromise;

this.isInitialized = true;
Expand Down Expand Up @@ -434,11 +442,6 @@ export class NestApplicationContext<
}
}

private async internalInit() {
await this.callInitHook();
await this.callBootstrapHook();
}

private getModulesToTriggerHooksOn(): Module[] {
if (this._moduleRefsForHooksByDistance) {
return this._moduleRefsForHooksByDistance;
Expand Down

0 comments on commit e64ab18

Please sign in to comment.