@@ -37,9 +37,9 @@ function getTopologyDescription(
3737
3838export function createInstanceStore (
3939 {
40- globalAppRegistry : appRegistry ,
40+ globalAppRegistry,
4141 dataService,
42- logger : { debug } ,
42+ logger : { log , mongoLogId } ,
4343 } : {
4444 dataService : DataService ;
4545 logger : LoggerAndTelemetry ;
@@ -57,19 +57,17 @@ export function createInstanceStore(
5757
5858 try {
5959 await instance . refresh ( { dataService, ...refreshOptions } ) ;
60-
61- appRegistry . emit ( 'instance-refreshed' , {
62- instance,
63- dataService,
64- errorMessage : '' ,
65- } ) ;
6660 } catch ( err : any ) {
67- appRegistry . emit ( 'instance-refreshed' , {
68- instance,
69- dataService,
70- errorMessage : err . message ,
71- } ) ;
72-
61+ log . warn (
62+ mongoLogId ( 1_001_000_295 ) ,
63+ 'Instance Store' ,
64+ 'Failed to refresh instance' ,
65+ {
66+ message : ( err as Error ) . message ,
67+ connectionId : dataService . id ,
68+ isFirstRun,
69+ }
70+ ) ;
7371 // The `instance.refresh` method is catching all expected errors: we treat
7472 // a lot of metadata as optional so failing to fetch it shouldn't throw.
7573 // In most cases if this failed on subsequent runs, user is probably
@@ -92,16 +90,28 @@ export function createInstanceStore(
9290 }
9391 }
9492
95- // Event emitted when the Databases grid needs to be refreshed
96- // We additionally refresh the list of collections as well
97- // since there is the side navigation which could be in expanded mode
93+ // Event emitted when the Databases grid needs to be refreshed. We
94+ // additionally refresh the list of collections as well since there is the
95+ // side navigation which could be in expanded mode
9896 async function refreshDatabases ( ) {
99- await instance . fetchDatabases ( { dataService, force : true } ) ;
100- await Promise . allSettled (
101- instance . databases . map ( ( db ) =>
102- db . fetchCollections ( { dataService, force : true } )
103- )
104- ) ;
97+ try {
98+ await instance . fetchDatabases ( { dataService, force : true } ) ;
99+ await Promise . allSettled (
100+ instance . databases . map ( ( db ) =>
101+ db . fetchCollections ( { dataService, force : true } )
102+ )
103+ ) ;
104+ } catch ( err : any ) {
105+ log . warn (
106+ mongoLogId ( 1_001_000_296 ) ,
107+ 'Instance Store' ,
108+ 'Failed to refresh databases' ,
109+ {
110+ message : ( err as Error ) . message ,
111+ connectionId : dataService . id ,
112+ }
113+ ) ;
114+ }
105115 }
106116
107117 async function fetchAllCollections ( ) {
@@ -174,12 +184,8 @@ export function createInstanceStore(
174184
175185 addCleanup ( ( ) => {
176186 instance . removeAllListeners ( ) ;
177- appRegistry . emit ( 'instance-destroyed' , { instance : null } ) ;
178187 } ) ;
179188
180- debug ( 'instance-created' ) ;
181- appRegistry . emit ( 'instance-created' , { instance } ) ;
182-
183189 void refreshInstance ( {
184190 fetchDatabases : true ,
185191 fetchDbStats : true ,
@@ -197,22 +203,22 @@ export function createInstanceStore(
197203
198204 on ( dataService , 'topologyDescriptionChanged' , onTopologyDescriptionChanged ) ;
199205
200- on ( appRegistry , 'sidebar-expand-database' , ( dbName : string ) => {
206+ on ( globalAppRegistry , 'sidebar-expand-database' , ( dbName : string ) => {
201207 void instance . databases . get ( dbName ) ?. fetchCollections ( { dataService } ) ;
202208 } ) ;
203209
204- on ( appRegistry , 'sidebar-filter-navigation-list' , fetchAllCollections ) ;
210+ on ( globalAppRegistry , 'sidebar-filter-navigation-list' , fetchAllCollections ) ;
205211
206- on ( appRegistry , 'refresh-data' , refreshInstance ) ;
212+ on ( globalAppRegistry , 'refresh-data' , refreshInstance ) ;
207213
208- on ( appRegistry , 'database-dropped' , ( dbName : string ) => {
214+ on ( globalAppRegistry , 'database-dropped' , ( dbName : string ) => {
209215 const db = instance . databases . remove ( dbName ) ;
210216 if ( db ) {
211217 MongoDBInstance . removeAllListeners ( db ) ;
212218 }
213219 } ) ;
214220
215- on ( appRegistry , 'collection-dropped' , ( namespace : string ) => {
221+ on ( globalAppRegistry , 'collection-dropped' , ( namespace : string ) => {
216222 const { database } = toNS ( namespace ) ;
217223 const db = instance . databases . get ( database ) ;
218224 const coll = db ?. collections . get ( namespace , '_id' ) ;
@@ -236,10 +242,10 @@ export function createInstanceStore(
236242 }
237243 } ) ;
238244
239- on ( appRegistry , 'refresh-databases' , refreshDatabases ) ;
245+ on ( globalAppRegistry , 'refresh-databases' , refreshDatabases ) ;
240246
241247 on (
242- appRegistry ,
248+ globalAppRegistry ,
243249 'collection-renamed' ,
244250 ( { from, to } : { from : string ; to : string } ) => {
245251 const { database, collection } = toNS ( from ) ;
@@ -250,16 +256,20 @@ export function createInstanceStore(
250256 }
251257 ) ;
252258
253- on ( appRegistry , 'document-deleted' , refreshNamespaceStats ) ;
254- on ( appRegistry , 'document-inserted' , refreshNamespaceStats ) ;
255- on ( appRegistry , 'import-finished' , refreshNamespaceStats ) ;
259+ on ( globalAppRegistry , 'document-deleted' , refreshNamespaceStats ) ;
260+ on ( globalAppRegistry , 'document-inserted' , refreshNamespaceStats ) ;
261+ on ( globalAppRegistry , 'import-finished' , refreshNamespaceStats ) ;
256262
257- on ( appRegistry , 'collection-created' , maybeAddAndRefreshCollectionModel ) ;
263+ on (
264+ globalAppRegistry ,
265+ 'collection-created' ,
266+ maybeAddAndRefreshCollectionModel
267+ ) ;
258268
259- on ( appRegistry , 'view-created' , maybeAddAndRefreshCollectionModel ) ;
269+ on ( globalAppRegistry , 'view-created' , maybeAddAndRefreshCollectionModel ) ;
260270
261271 on (
262- appRegistry ,
272+ globalAppRegistry ,
263273 'agg-pipeline-out-executed' ,
264274 // null means the out / merge stage destination wasn't a namespace in the
265275 // same cluster
@@ -271,7 +281,7 @@ export function createInstanceStore(
271281 }
272282 ) ;
273283
274- on ( appRegistry , 'view-edited' , ( namespace : string ) => {
284+ on ( globalAppRegistry , 'view-edited' , ( namespace : string ) => {
275285 const { database } = toNS ( namespace ) ;
276286 void instance . databases
277287 . get ( database )
0 commit comments