File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
packages/compass-app-stores/src/stores Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -320,26 +320,36 @@ export function createInstancesStore(
320320 connections . getDataServiceForConnection ( instanceConnectionId ) ;
321321 const connectionString = dataService . getConnectionString ( ) ;
322322 const firstHost = connectionString . hosts [ 0 ] || '' ;
323- const [ hostname , port ] = firstHost . split ( ':' ) ;
323+ const [ hostname , port ] = ( ( ) => {
324+ if ( firstHost . startsWith ( '[' ) ) {
325+ return firstHost . slice ( 1 ) . split ( ']' ) ; // IPv6
326+ }
327+ return firstHost . split ( ':' ) ;
328+ } ) ( ) ;
324329
325330 const initialInstanceProps : Partial < MongoDBInstanceProps > = {
331+ // We pre-fetched instance info and so can right away construct it in a
332+ // "ready" state
333+ ...( instanceInfo as Partial < MongoDBInstanceProps > ) ,
334+ status : 'ready' ,
335+ statusError : null ,
336+
337+ // Required initial values that are not returned with instance info
326338 _id : firstHost ,
327339 hostname : hostname ,
328340 port : port ? + port : undefined ,
329341 topologyDescription : getTopologyDescription (
330342 dataService . getLastSeenTopology ( )
331343 ) ,
344+
345+ // Service injection for preferences (currently only controls namespace
346+ // stats fetching)
332347 preferences,
333348 } ;
334349 const instance = instancesManager . createMongoDBInstanceForConnection (
335350 instanceConnectionId ,
336351 initialInstanceProps as MongoDBInstanceProps
337352 ) ;
338- instance . set ( {
339- status : 'ready' ,
340- statusError : null ,
341- ...( instanceInfo as Partial < MongoDBInstanceProps > ) ,
342- } ) ;
343353
344354 addCleanup ( ( ) => {
345355 instance . removeAllListeners ( ) ;
You can’t perform that action at this time.
0 commit comments