NestJS · Middle · Question 20 of 75
Which lifecycle hook is the right place to open a connection that other modules rely on during startup?
- ✓Correct answer:
onModuleInit(or an async factory provider) - 2The class constructor, with
await - 3
onApplicationShutdown
Explanation
Constructors can't be async. Nest awaits async onModuleInit hooks before calling onApplicationBootstrap.