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

ctrl-c does not kill a mongosh script that's monitoring a watch cursor

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Critical - P2 Critical - P2
    • 1.9.0
    • Affects Version/s: None
    • Component/s: CLI Module
    • None
    • Environment:
      OS:
      node.js / npm versions:
      Additional info:
    • 5
    • Not Needed
    • Iteration Brontosaurus

      Here's my test watch-script.js:

      watchCursor = db.watch();
      while (!watchCursor.isClosed()) {
        let next = watchCursor.tryNext()
        while (next !== null) {
          printjson(next);
          next = watchCursor.tryNext()
        }
      }
      

      (This is taken from https://www.mongodb.com/docs/manual/reference/method/db.collection.watch/)

      I ran it using:

      mongosh {connection-string} watch-script.js
      

      It prints new events on that db, but I can't exit the script with ctrl-c.

            Assignee:
            sergey.petushkov@mongodb.com Sergey Petushkov
            Reporter:
            leroux.bodenstein@mongodb.com Le Roux Bodenstein
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: