Skip to content

Commit

Permalink
fixup: unconditionally call fetchConnections() on startup (but do not…
Browse files Browse the repository at this point in the history
… always wait for result)
  • Loading branch information
addaleax committed Apr 24, 2024
1 parent 40d6d23 commit f2842ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
21 changes: 1 addition & 20 deletions packages/cli-repl/src/cli-repl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1519,25 +1519,6 @@ describe('CliRepl', function () {
cliRepl,
await testServer.connectionString()
);
expect(
requests
.flatMap((req) =>
JSON.parse(req.body).batch.map((entry) => entry.event)
)
.sort()
.filter(Boolean)
).to.deep.equal(['API Call', 'Script Evaluated', 'Startup Time']);
expect(totalEventsTracked).to.equal(4);
});

it('includes an additional event for connection info if not in quiet mode', async function () {
cliReplOptions.shellCliOptions.eval = ['db.hello()'];
cliReplOptions.shellCliOptions.quiet = false;
cliRepl = new CliRepl(cliReplOptions);
await startWithExpectedImmediateExit(
cliRepl,
await testServer.connectionString()
);
expect(
requests
.flatMap((req) =>
Expand All @@ -1564,7 +1545,7 @@ describe('CliRepl', function () {
cliRepl,
await testServer.connectionString()
);
expect(totalEventsTracked).to.equal(6);
expect(totalEventsTracked).to.equal(7);

const apiEvents = requests
.map((req) =>
Expand Down
5 changes: 4 additions & 1 deletion packages/cli-repl/src/mongosh-repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ class MongoshNodeRepl implements EvaluationListener {
// not-quiet mode -> We'll need it for the greeting message (and need it now)
// REPL mode -> We'll want it for fast autocomplete (and need it soon-ish, but not now)
instanceState.setPreFetchCollectionAndDatabaseNames(!usePlainVMContext);
if (!this.shellCliOptions.quiet || !usePlainVMContext) {
// `if` commented out because we currently still want the connection info for
// logging/telemetry but we may want to revisit that in the future:
// if (!this.shellCliOptions.quiet || !usePlainVMContext)
{
const connectionInfoPromise = instanceState.fetchConnectionInfo();
connectionInfoPromise.catch(() => {
// Ignore potential unhandled rejection warning
Expand Down

0 comments on commit f2842ee

Please sign in to comment.