-
Type: Bug
-
Resolution: Gone away
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.0.4
-
Component/s: None
-
Environment:os : macOS 10.13.3
node : 9.8.0
mongo-server : 3.4.14
-
Empty show more show less
-
Not Needed
When closing and reopening a connection where a db was cached, the cached db is not notified of the reconnection (db.serverConfig.isDestroyed() === true).
Code to reproduce:
const MongoClient = require('mongodb').MongoClient; async function fun() { // Connect const client = new MongoClient('mongodb://localhost:27017'); await client.connect(); // Put db in cache let col = client.db('foo').collection('bar'); await col.insert({ foo: 'bar' }); // Disconnect await client.close(); // Reconnect await client.connect(); try { console.log('Destroyed ===', client.db('foo').serverConfig.isDestroyed()); // => true col = client.db('foo').collection('bar'); // will fail await col.insert({ foo: 'bar' }); } finally { await client.close(); } } fun().then(console.log).catch(console.error);
- related to
-
NODE-2544 Can't reuse mongo client after close
- Closed