Skip to content

Commit 7ce850e

Browse files
committed
docs(lifecycle-events): better phrasing for app shutdown
1 parent d95a9e1 commit 7ce850e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

content/fundamentals/lifecycle-events.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async onModuleInit() {
6666

6767
The `beforeApplicationShutdown()` and `onApplicationShutdown()` hooks are called in the **terminating** phase (in response to system signals such as `SIGTERM`). This feature is often used with [Kubernetes](https://kubernetes.io/), [Heroku](https://www.heroku.com/) or similar services.
6868

69-
> warning **warning** Due to inherent platform limitations, NestJS has limited support for Windows. You can expect `SIGINT` to work, as well as `SIGBREAK` and to some extent `SIGHUP`. However `SIGTERM` will never work on Windows because killing a process in the task manager is unconditional, i.e., there's no way for an application to detect or prevent it. Here's some [relevant documentation](http://docs.libuv.org/en/v1.x/signal.html) from libuv to learn more about what `SIGINT`, `SIGBREAK` etc. signify and what's supported on Windows. Also, see Node.js documentation of [Process Signal Events](https://nodejs.org/api/process.html#process_signal_events)
69+
> warning **warning** Due to inherent platform limitations, NestJS has limited support for application shutdown hooks on Windows. You can expect `SIGINT` to work, as well as `SIGBREAK` and to some extent `SIGHUP` - [read more](https://nodejs.org/api/process.html#process_signal_events). However `SIGTERM` will never work on Windows because killing a process in the task manager is unconditional, "i.e., there's no way for an application to detect or prevent it". Here's some [relevant documentation](http://docs.libuv.org/en/v1.x/signal.html) from libuv to learn more about how `SIGINT`, `SIGBREAK` and others are handled on Windows. Also, see Node.js documentation of [Process Signal Events](https://nodejs.org/api/process.html#process_signal_events)
7070
7171
To use these hooks you must activate a listener which listens to shutdown signals.
7272

@@ -83,7 +83,7 @@ async function bootstrap() {
8383
bootstrap();
8484
```
8585

86-
> info **Info** `enableShutdownHooks` is disabled by default because the application could run into memory leak issues in case multiple Nest instances are running (e.g. testing). Node.js would warn you, in case you have too many listeners running in parallel and prevent you from having major memory leaks.
86+
> info **Info** `enableShutdownHooks` consumes memory by starting listeners. In cases where you are running multiple Nest apps in a single Node process (e.g., when running parallel tests with Jest), Node may complain about excessive listener processes. For this reason, `enableShutdownHooks` is not enabled by default. Be aware of this condition when you are running multiple instances in a single Node process.
8787
8888
When the application receives a termination signal it will call any registered `beforeApplicationShutdown()`, then `onApplicationShutdown()` methods (in the sequence described above) with the corresponding signal as the first parameter. If a registered function awaits an asynchronous call (returns a promise), Nest will not continue in the sequence until the promise is resolved or rejected.
8989

0 commit comments

Comments
 (0)