Uploaded image for project: 'MongoDB Shell'
  1. MongoDB Shell
  2. MONGOSH-727

Shell gets into a unrecoverable bad state when pasting in invalid code

    • 3
    • Not Needed
    • Iteration Barcelona

      Problem Description

      Pasting invalid JS code into the shell gets into a bad state that it can't recover from without exiting.

      Steps to Reproduce

      • Open mongosh
      • Paste the snippet below
      var collName = 'somecoll';
      var coll = db[collName];
      -
      coll.drop();
      coll.insertOne({'val': 'abc'});
      -
      var pipeline = [
        {"$unset": [
          "_id",
        ]},
      
        {"$merge": {
          "into": collName,
          "on": "_id",
          "whenMatched": "fail",
          "whenNotMatched": "insert"
        }},     
      ];
      -
      for (let i=0; i<3; i++) {
        coll.aggregate(pipeline).next();
        print(new Date() + ' - Count: ' + coll.countDocuments({}) + ', Size: ' + coll.stats().totalSize);
      }
      
      

      Expected Results

      Errors are displayed, prompt is back and things work just fine.

      Actual Results

      Additional Notes

            Assignee:
            anna.henningsen@mongodb.com Anna Henningsen
            Reporter:
            massimiliano.marcon@mongodb.com Massimiliano Marcon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: