Skip to content

Commit

Permalink
fix(cli-repl): drop nanobus in production usage MONGOSH-1330 (#1366)
Browse files Browse the repository at this point in the history
nanobus inherently leaks memory, which means that it can
make mongosh crash in certain scenarios.

Since we do not actually use the features of nanobus
(mostly being able to listen for a generic `'*'` event),
just replace it with the standard `EventEmitter` to fix this.
  • Loading branch information
addaleax authored Dec 2, 2022
1 parent 470b2b7 commit afce071
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 78 deletions.
75 changes: 0 additions & 75 deletions packages/cli-repl/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/cli-repl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
"js-yaml": "^4.1.0",
"mongodb-connection-string-url": "^2.5.3",
"mongodb-log-writer": "^1.1.3",
"nanobus": "^4.4.0",
"numeral": "^2.0.6",
"pretty-repl": "^3.1.1",
"semver": "^7.1.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli-repl/src/cli-repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import { Editor } from '@mongosh/editor';
import { redactSensitiveData } from '@mongosh/history';
import Analytics from 'analytics-node';
import askpassword from 'askpassword';
import { EventEmitter } from 'events';
import yaml from 'js-yaml';
import ConnectionString from 'mongodb-connection-string-url';
import Nanobus from 'nanobus';
import semver from 'semver';
import { Readable, Writable } from 'stream';
import { buildInfo } from './build-info';
Expand Down Expand Up @@ -104,7 +104,7 @@ class CliRepl implements MongoshIOProvider {
* Instantiate the new CLI Repl.
*/
constructor(options: CliReplOptions) {
this.bus = new Nanobus('mongosh');
this.bus = new EventEmitter();
this.cliOptions = options.shellCliOptions;
this.input = options.input;
this.output = options.output;
Expand Down

0 comments on commit afce071

Please sign in to comment.