Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-506

What is the proper error handling mechanism for bulk/batch operations?

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.0.40
    • Affects Version/s: 2.0.37
    • Component/s: None

      I'm not sure if the bulk/batch execute() operations are bugged or have a confusing spec and/or missing documentation documentation.

      Example:

      var batch = collection.initializeUnorderedBulkOp();
      batch.insert(

      { foo : "a" }

      );
      batch.insert(

      { foo : "a" }

      );

      batch.execute(function(err, result)

      { // what does err represent? // what do we do with result.getWriteErrors() }

      );

      In other parts of the code you're careful to run all errors through utils.toError(). The part of the code base which may handle this problem is line 284 in common.js, but that line is commented out in the common, is that intentional?

      My preference is that the first argument of the execute callback would always be instanceof Error, and would exist regardless of whether the error was a writeError, writeConcernError, or "top level error" as it says in the code. Is that the intention? That's basically the way it's handled in multi-item insert/update statements, so it would be nice to adhere to the same philosophy. I can submit a pull request to try and fix but wasn't sure on the intention.

            Assignee:
            christkv Christian Amor Kvalheim
            Reporter:
            owenallenaz Owen Allen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: