Skip to content

ShutdownHooksOptions

reference
1 min readUpdated

Kind: Interface

Source: packages/common/interfaces/shutdown-hooks-options.interface.ts

Part of: Common

Options for configuring shutdown hooks behavior.

ShutdownHooksOptions configures how application shutdown hooks behave. It currently controls whether the shutdown process should explicitly terminate the Node.js process after registered cleanup handlers have completed.

Properties

PropertyType
useProcessExitboolean

Diagram

mermaid
graph LR
  A[Application shutdown signal] --> B[Shutdown hooks handler]
  B --> C[Run registered cleanup hooks]
  C --> D{useProcessExit?}
  D -->|true| E[Call process.exit]
  D -->|false| F[Allow event loop to exit naturally]

Usage

ts
import type { ShutdownHooksOptions } from '@package/common';

const shutdownOptions: ShutdownHooksOptions = {
  useProcessExit: true,
};

// Pass options when configuring the application's shutdown handling.
configureShutdownHooks(shutdownOptions);

AI Coding Instructions

  • Set useProcessExit to true only when the application must terminate immediately after cleanup hooks finish.
  • Prefer false when open resources should be allowed to close naturally through the Node.js event loop.
  • Ensure shutdown hooks complete asynchronous cleanup before process termination is triggered.
  • Keep this interface focused on shutdown behavior; add new lifecycle configuration options as explicit, typed fields.

Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Imported by (1)

  • NestApplicationContextpackages/core/nest-application-context.ts:40

Was this page helpful?

Download as PDF
ShutdownHooksOptions — NestJS head-to-head