Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli-repl): do not wait for connectionInfo in quiet non-REPL mode MONGOSH-1765 #1962

Merged
merged 3 commits into from
Apr 24, 2024

Conversation

addaleax
Copy link
Contributor

@addaleax addaleax commented Apr 24, 2024

Do not call wait for fetchConnectionInfo() and similar methods when they are not needed. This hopefully improves startup performance in real-world scenarios a bit further.

In order to achieve this:

  • Implement a cache/lazy-loading ability for the connection info in the shell-api ShellInstanceState class. We now only fetch connection info here if requested, and only refresh it if the service provider instance changed (and not just the database itself).
  • Adjust usage of the fetchConnectionInfo() method to only be called if we believe it to be necessary, and for its result to be awaited only if we need it immediately.

This also adds type safety by removing the any typing for connectionInfo in ShellInstanceState. I admittedly thought that this would be a quick fix, but unfortunately (as seen in the commit diff), this spiraled a bit into different packages and tests as a larger change to align the typings for this object.

…OSH-1765

Do not call `fetchConnectionInfo()` and similar methods when they are
not needed. This hopefully improves startup performance in real-world
scenarios a bit further.

In order to achieve this:
- Implement a cache/lazy-loading ability for the connection info
  in the shell-api `ShellInstanceState` class. We now only fetch
  connection info here if requested, and only refresh it
  if the service provider instance changed (and not just the
  database itself).
- Adjust usage of the `fetchConnectionInfo()` method to only
  be called if we believe it to be necessary, and for its result
  to be awaited only if we need it immediately.

This also adds type safety by removing the `any` typing for
`connectionInfo` in `ShellInstanceState`. I admittedly thought
that this would be a quick fix, but unfortunately (as seen in the
commit diff), this spiraled a bit into different packages and tests
as a larger change to align the typings for this object.
@addaleax addaleax changed the title fix(cli-repl): do not load connectionInfo in quiet non-REPL mode MONGOSH-1765 fix(cli-repl): do not wait for connectionInfo in quiet non-REPL mode MONGOSH-1765 Apr 24, 2024
@addaleax addaleax merged commit 3a95f1d into main Apr 24, 2024
56 of 58 checks passed
@addaleax addaleax deleted the 1765-dev branch April 24, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants