Relative Content

Tag Archive for nestjs

In Nest.js, how to tap into lifecyle events from durable providers to release db connections

I have created a durable provider to return a db connection for a given tenant. The provider will also keep a local cache of connections to reuse. As request-scoped providers cannot tap into application lifecycle events, I don’t have a way to trigger closing the connections when app.close() is triggered. In my example below, onModuleDestroy will never be called, which results in Jest warnings like