title: MongoCursorException - Cursor not found (MongoDB PHP Driver)
body: <p><strong>Code</strong>:</p>
  
  <pre><code>try {
    $documentsFind = $client-&gt;$db-&gt;$collection-&gt;find([
        // query
    ]);
    if ($documentsFind) {
      foreach ($documentsFind as $product) {
      // code...
      }
    }
  catch (MongoCursorException $e) {
    echo "error message: ".$e-&gt;getMessage()."\n";
    echo "error code: ".$e-&gt;getCode()."\n";
  }
  </code></pre>
  
  <p><strong>Error</strong>:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught MongoDB\Driver\Exception\RuntimeException:
    Cursor not found, cursor id: 31837896248 in ...</p>
  </blockquote>
  
  <p>It seems that the cursor does exist but times out? How can I prevent that from happening?</p>
  
  <p><strong>Edited to add</strong>: I tried doing:</p>
  
  <pre><code> if ($documentsFind) {
      $documentsFind-&gt;immortal(true); // keep alive
      foreach ($documentsFind as $product) {
      // code...
      }
    }
  </code></pre>
  
  <p>But that results in <code>Call to undefined method MongoDB\Driver\Cursor::immortal()</code>. </p>