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

Uncatchable exceptions

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.1.13
    • Fix Version/s: 3.2.0
    • Component/s: core
    • Labels:
    • MongoDB Version:
      Not Applicable

      Description

      the code below
       

      var uri = 'mongodb://undefined@cluster0-shard-00-';
      (async function() {
        let db; 
        try {
          db = await MongoClient.connect(uri, { useNewUrlParser: true });
          console.log("RETURN", db);
        } catch (err){
          console.log('EXITING');
          process.exit(1);
        }
      }());
      

       fails to catch the error generated.  the error owes to the undefined value of the credentials and if replaced with

      var uri = 'mongodb://x:y@cluster0-shard-00-';

      produces an exception about authentication failure as expected but the absence of a colon in the credentials causes an untrappable error

      the problem is that the caller reasonably expects to be able to trap any issue without having to resort to the uncaughtException mechanism in Javascript

      A link to my original post can be found here: https://stackoverflow.com/questions/54737280/catch-fails-on-connection-to-mongo

       

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: