Details
-
Improvement
-
Status: Closed
-
Major - P3
-
Resolution: Fixed
-
None
-
None
-
None
-
Empty show more show less
Description
Running the following snippet will result in a Maximum call stack exceeded error:
const { MongoClient } = require('mongodb');
|
async function main(pid) {
|
const client = new MongoClient('mongodb://localhost:27017/', { useNewUrlParser: true, useUnifiedTopology: true });
|
await client.connect()
|
|
const collection = client.db().collection('test');
|
await collection.insertOne({ a: 42 });
|
for (let counter = 0; counter < 100000; counter++) {
|
collection.insertOne({ a: 42 }, _ => {});
|
}
|
|
await client.close();
|
}
|
|
main().catch(console.error);
|
The logic for processing the wait queue in the ConnectionPool attempts to process wait queue members in a very tight, greedy loop. We must use process.nextTick in order to let the runtime process background tasks, as well as allowing the garbage collector to run.
Attachments
Issue Links
- causes
-
NODE-2861 Performance Regression for usage of mongodb connections (queries, inserts, ...)
-
- Closed
-