Skip to content

Commit 0eb9d59

Browse files
authored
fix(shell-api): catch Promise rejections caused by db switch (#582)
Make sure we’re not running into unhandled rejections when updating information after a database switch.
1 parent a700fcc commit 0eb9d59

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/shell-api/src/shell-internal-state.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,9 @@ export default class ShellInternalState {
126126
this.currentDb = newDb;
127127
this.context.rs = new ReplicaSet(this.currentDb);
128128
this.context.sh = new Shard(this.currentDb);
129-
this.fetchConnectionInfo();
130-
this.currentDb._getCollectionNames(); // Pre-fetch for autocompletion.
129+
this.fetchConnectionInfo().catch(err => this.messageBus.emit('mongosh:error', err));
130+
// Pre-fetch for autocompletion.
131+
this.currentDb._getCollectionNames().catch(err => this.messageBus.emit('mongosh:error', err));
131132
return newDb;
132133
}
133134

0 commit comments

Comments
 (0)