title: Why doesn't callback in db.collection().find().toArray(callback) get called if database connection is dropped?
body: <p>I have this code:</p>
  
  <pre><code>db.collection('users').find({ active: true ).toArray(callback);
  </code></pre>
  
  <p>where db is an opened database connection to my local mongodb server. This works fine. But if I manually close my mongodb server while my app is still running, and then execute this line of code, callback is never executed, not even with error. Is this expected behaviour? What can I do to make my app react to dropped database connection?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I tried this:</p>
  
  <pre><code>db.collection('users')
    .find({active: true}, function(err, cursor) {
      if (err) callback(err);
      else cursor.toArray(callback);
    });
  </code></pre>
  
  <p>Again, this works when connection is alive, but when connection is dropped, the anonymous callback function of find() is called with 'err' as null - and the callback of .toArray is not called at all. How do I rewrite my code so that I get an error if db connection is not alive?</p>