@@ -237,9 +237,16 @@ export class IntegrationService implements Disposable {
237
237
}
238
238
239
239
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
+ ) ;
243
250
}
244
251
}
245
252
@@ -459,6 +466,24 @@ export class IntegrationService implements Disposable {
459
466
) . GitHubIntegration ( this . container , this . authenticationService , this . getProvidersApi . bind ( this ) ) ;
460
467
break ;
461
468
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 ;
462
487
case SelfHostedIntegrationId . GitHubEnterprise :
463
488
if ( domain == null ) throw new Error ( `Domain is required for '${ id } ' integration` ) ;
464
489
integration = new (
@@ -883,6 +908,16 @@ export class IntegrationService implements Disposable {
883
908
return this . _integrations . get ( this . getCacheKey ( id , domain ) ) ;
884
909
}
885
910
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
+
886
921
private getCacheKey (
887
922
id : SupportedHostingIntegrationIds | SupportedIssueIntegrationIds | SupportedSelfHostedIntegrationIds ,
888
923
domain ?: string ,
0 commit comments