Skip to content

Commit

Permalink
fix(connection): call setMaxListeners(0) on MongoClient to avoid ev…
Browse files Browse the repository at this point in the history
…ent emitter memory leak warnings with `useDb()`

Fix #10762
  • Loading branch information
vkarpov15 committed Oct 11, 2021
1 parent d99f42c commit 30efc39
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/connection.js
Expand Up @@ -832,6 +832,7 @@ Connection.prototype.openUri = function(uri, options, callback) {
const promise = new Promise((resolve, reject) => {
const client = new mongodb.MongoClient(uri, options);
_this.client = client;
client.setMaxListeners(0);
client.connect((error) => {
if (error) {
return reject(error);
Expand Down

0 comments on commit 30efc39

Please sign in to comment.