Skip to content

Commit 1e33cb4

Browse files
authored
Ensure app is closed using try/finally (#1211)
When calling `CommandFactory.run()`, ensure that the app is closed by wrapping it in a try/finally clause.
2 parents c583b65 + 6b75e0e commit 1e33cb4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/nest-commander/src/command.factory.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ export class CommandFactory {
1919
optionsOrLogger?: CommandFactoryRunOptions | NestLogger,
2020
): Promise<void> {
2121
const app = await this.createWithoutRunning(rootModule, optionsOrLogger);
22-
await this.runApplication(app);
23-
await app.close();
22+
try {
23+
await this.runApplication(app);
24+
} finally {
25+
await app.close();
26+
}
2427
}
2528

2629
static async runWithoutClosing(

0 commit comments

Comments
 (0)