Skip to content

Commit 218ab96

Browse files
bugfix(core): fix hanging process (add process.exit - lifecycle hook)
1 parent 7582572 commit 218ab96

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

packages/core/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export const SHUTDOWN_SIGNALS = [
1818
'SIGABRT',
1919
'SIGBUS',
2020
'SIGFPE',
21-
'SIGUSR1',
2221
'SIGSEGV',
2322
'SIGUSR2',
2423
'SIGTERM',

packages/core/nest-application-context.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { INestApplicationContext, Logger, LoggerService } from '@nestjs/common';
22
import { Type } from '@nestjs/common/interfaces/type.interface';
3+
import { SHUTDOWN_SIGNALS } from './constants';
34
import { UnknownModuleException } from './errors/exceptions/unknown-module.exception';
4-
import { NestContainer } from './injector/container';
5-
import { ContainerScanner } from './injector/container-scanner';
6-
import { Module } from './injector/module';
7-
import { ModuleTokenFactory } from './injector/module-token-factory';
85
import {
9-
callModuleInitHook,
6+
callAppShutdownHook,
107
callModuleBootstrapHook,
118
callModuleDestroyHook,
12-
callAppShutdownHook,
9+
callModuleInitHook,
1310
} from './hooks';
14-
import { SHUTDOWN_SIGNALS } from './constants';
11+
import { NestContainer } from './injector/container';
12+
import { ContainerScanner } from './injector/container-scanner';
13+
import { Module } from './injector/module';
14+
import { ModuleTokenFactory } from './injector/module-token-factory';
1515

1616
export class NestApplicationContext implements INestApplicationContext {
1717
private readonly moduleTokenFactory = new ModuleTokenFactory();
@@ -74,9 +74,10 @@ export class NestApplicationContext implements INestApplicationContext {
7474

7575
protected listenToShutdownSignals() {
7676
SHUTDOWN_SIGNALS.forEach((signal: any) =>
77-
process.on(signal, async () => {
77+
process.on(signal, async code => {
7878
await this.callDestroyHook();
7979
await this.callShutdownHook(signal);
80+
process.exit(code || 1);
8081
}),
8182
);
8283
}

0 commit comments

Comments
 (0)