@@ -237,9 +237,16 @@ export class IntegrationService implements Disposable {
237237 }
238238
239239 for ( const integrationId of integrationIds ) {
240- const integration = await this . get ( integrationId ) ;
241- if ( integration . maybeConnected ?? ( await integration . isConnected ( ) ) ) {
242- connectedIntegrations . add ( integrationId ) ;
240+ try {
241+ const integration = await this . get ( integrationId ) ;
242+ if ( integration . maybeConnected ?? ( await integration . isConnected ( ) ) ) {
243+ connectedIntegrations . add ( integrationId ) ;
244+ }
245+ } catch ( ex ) {
246+ Logger . log (
247+ `Failed to get integration ${ integrationId } by its ID. Consider it as not-connected and ignore. Error message: ${ ex . message } ` ,
248+ scope ,
249+ ) ;
243250 }
244251 }
245252
@@ -459,6 +466,24 @@ export class IntegrationService implements Disposable {
459466 ) . GitHubIntegration ( this . container , this . authenticationService , this . getProvidersApi . bind ( this ) ) ;
460467 break ;
461468 case SelfHostedIntegrationId . CloudGitHubEnterprise :
469+ if ( domain == null ) {
470+ integration = this . findCachedById ( id ) ;
471+ if ( integration != null ) {
472+ // return immediately in order to not to cache it after the "switch" block:
473+ return integration ;
474+ }
475+ throw new Error ( `Domain is required for '${ id } ' integration` ) ;
476+ }
477+ integration = new (
478+ await import ( /* webpackChunkName: "integrations" */ './providers/github' )
479+ ) . GitHubEnterpriseIntegration (
480+ this . container ,
481+ this . authenticationService ,
482+ this . getProvidersApi . bind ( this ) ,
483+ domain ,
484+ id ,
485+ ) ;
486+ break ;
462487 case SelfHostedIntegrationId . GitHubEnterprise :
463488 if ( domain == null ) throw new Error ( `Domain is required for '${ id } ' integration` ) ;
464489 integration = new (
@@ -883,6 +908,16 @@ export class IntegrationService implements Disposable {
883908 return this . _integrations . get ( this . getCacheKey ( id , domain ) ) ;
884909 }
885910
911+ private findCachedById ( id : SupportedSelfHostedIntegrationIds ) : Integration | undefined {
912+ const key = this . getCacheKey ( id , '' ) ;
913+ for ( const [ k , integration ] of this . _integrations ) {
914+ if ( k . startsWith ( key ) ) {
915+ return integration ;
916+ }
917+ }
918+ return undefined ;
919+ }
920+
886921 private getCacheKey (
887922 id : SupportedHostingIntegrationIds | SupportedIssueIntegrationIds | SupportedSelfHostedIntegrationIds ,
888923 domain ?: string ,
0 commit comments