Recall & Review
beginner
What is the Application Lifecycle in NestJS?
It is the sequence of events from starting the app, running it, to shutting it down, including hooks to run code at each stage.
Click to reveal answer
beginner
Name the lifecycle hook used to run code right after the application has fully started.
The hook is called
onApplicationBootstrap().Click to reveal answer
intermediate
What is the purpose of the
onModuleDestroy() hook in NestJS?It allows you to run cleanup code when a module is about to be destroyed, like closing database connections.
Click to reveal answer
intermediate
How does NestJS handle graceful shutdown of an application?
NestJS listens for shutdown signals and calls lifecycle hooks like
onApplicationShutdown() to clean resources before exit.Click to reveal answer
intermediate
Which interface should a service implement to run code when the application is shutting down?
Implement the
OnApplicationShutdown interface and define the onApplicationShutdown() method.Click to reveal answer
Which lifecycle hook runs after a module is initialized in NestJS?
✗ Incorrect
onModuleInit() runs after a module is initialized.What does the
onApplicationBootstrap() hook do?✗ Incorrect
onApplicationBootstrap() runs after the whole app is ready.Which interface is used to handle cleanup during app shutdown?
✗ Incorrect
OnApplicationShutdown is for cleanup during shutdown.What signal does NestJS listen for to trigger graceful shutdown?
✗ Incorrect
NestJS listens for
SIGINT to start shutdown.Which lifecycle hook is NOT part of NestJS application lifecycle?
✗ Incorrect
onAppStart is not a NestJS lifecycle hook.Explain the main lifecycle hooks in NestJS and when they run.
Think about the app starting, running, and stopping phases.
You got /4 concepts.
Describe how NestJS supports graceful shutdown and why it is important.
Consider what happens when you stop a running app.
You got /4 concepts.