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

MaxListenersExceededWarning for interrupted event unexpectedly triggered when writing to the stdio in mongosh in one evaluation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 1.0.1
    • Fix Version/s: 1.0.2
    • Component/s: Shell API
    • Labels:
      None
    • Story Points:
      2
    • Documentation Changes:
      Not Needed
    • Sprint:
      Iteration Hamburg

      Description

      Problem Statement/Rationale

      Seems like multiple writes to stdio directly from a singe mongosh evaluation leaks listeners on the mongosh cli interrupt implementation, this doesn't seem to break anything but produces an unexpected warning in the output

      Steps to Reproduce

      mongosh --nodb --quiet --eval "for (let i = 0; i < 11; i++) { console.log('hi'); }"
      

      Expected Results

      hi is printed on the screen eleven times

      Actual Results

      hi is printed on the screen eleven times but also a warning about max listeners:

      > for (let i = 0; i < 11; i++) { console.log('hi'); };
      (node:33596) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 interrupted listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit
      (Use `node --trace-warnings ...` to show where the warning was created)
      hi
      hi
      hi
      hi
      hi
      hi
      hi
      hi
      hi
      hi
      hi
      

      Additional Notes

      • Using print instead of console.log directly avoids causing the issue
      • It doesn't matter if it's stdout or stderr, changing console.log to console.error in the example above still causes the issue

        Attachments

          Activity

            People

            Assignee:
            michael.rose Michael Rose (Inactive)
            Reporter:
            sergey.petushkov Sergey Petushkov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: