From 9f5f505fc531e85fea949f82773ebff02df22caf Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 27 Jan 2021 14:35:28 +0100 Subject: [PATCH] fix(shell-api): catch Promise rejections caused by db switch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure we’re not running into unhandled rejections when updating information after a database switch. --- packages/shell-api/src/shell-internal-state.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/shell-api/src/shell-internal-state.ts b/packages/shell-api/src/shell-internal-state.ts index dfd40297bd..dc1f3f05cf 100644 --- a/packages/shell-api/src/shell-internal-state.ts +++ b/packages/shell-api/src/shell-internal-state.ts @@ -126,8 +126,9 @@ export default class ShellInternalState { this.currentDb = newDb; this.context.rs = new ReplicaSet(this.currentDb); this.context.sh = new Shard(this.currentDb); - this.fetchConnectionInfo(); - this.currentDb._getCollectionNames(); // Pre-fetch for autocompletion. + this.fetchConnectionInfo().catch(err => this.messageBus.emit('mongosh:error', err)); + // Pre-fetch for autocompletion. + this.currentDb._getCollectionNames().catch(err => this.messageBus.emit('mongosh:error', err)); return newDb; }