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

Uncatchable exceptions

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.2.0
    • Affects Version/s: 3.1.13
    • Component/s: Core

      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

       

            Assignee:
            katherine.walker@mongodb.com Katherine Walker (Inactive)
            Reporter:
            ekkis erick calder
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: