|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70509 Method MongoCursor::maxTimeMS doesn't always throw timeout exception
Submitted: 2015-09-16 10:24 UTC Modified: -
From: fabrice at workdigital dot co dot uk Assigned:
Status: Open Package: mongo (PECL)
PHP Version: 5.6.13 OS: Debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: fabrice at workdigital dot co dot uk
New email:
PHP Version: OS:


 [2015-09-16 10:24 UTC] fabrice at workdigital dot co dot uk
Contrary as what the documentation says, MongoCursor::maxTimeMS() doesn't always throws MongoExecutionTimeoutException, it doesn't work this way when you use next() on the cursor.
See the working script examples for details!

Test script:
// Currently throwing exception (fine!)

    // Any slightly big collection should do here
    $cursor = $mongo->test->test->find(['i' => 9999999])->maxTimeMS(1);
    // $doc = iterator_to_array($cursor);
    foreach ($cursor as $item) {

// Doesn't throw an exception (bad!)
    $doc = $mongo->test->test->find(['i' => 9999999])->maxTimeMS(1)->next();
    // Will display:
    // array(2) {
    // '$err' =>
    // string(29) "operation exceeded time limit"
    //  'code' =>
    // int(50)
    // }


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 20:01:31 2024 UTC