The following code opens a connection as soon as the first api request comes in and prints out “connection created”. But it is never closed.
this.client = await MongoClient.connect(this.config.connectionURL, {
minPoolSize: 0,
maxPoolSize: 10,
maxIdleTimeMS: 5000,
});
this.client.on('connectionClosed', () => {
console.log('connection closed');
});
this.client.on('connectionCreated', () => {
console.log('connection created');
});