-
Type:
Bug
-
Resolution: Done
-
Priority:
Minor - P4
-
None
-
Affects Version/s: 4.4.1
-
Component/s: None
What problem are you facing?
When a connection is closed and the internal topology is destroyed, operations attempting to execute will get a thrown MongoNotConnectedError instead of the error being based passed to the callback of the operation.
What driver and relevant dependency versions are you using?
4.4.1
Steps to reproduce?
const { MongoClient } = require('mongodb'); const repro = () => { const client = new MongoClient('mongodb://127.0.0.1:27017'); client.connect((error) => { const db = client.db('test'); const collection = db.collection('test'); client.close(() => { // This will throw an error instead of passing in the callback. collection.find().toArray((err) => { console.log(err); }); }); }); } repro();