Skip to content

Commit 8f61e02

Browse files
committed
Fixes #4065 handles auth timeout
Handles auth timeout errors for when user disables auth extensions Special-cases GitHub auth check to avoid timeout delay
1 parent 241f236 commit 8f61e02

File tree

3 files changed

+53
-39
lines changed

3 files changed

+53
-39
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
2828
- Fixes incorrect PR Link Across Azure DevOps Projects ([#4207](https://github.com/gitkraken/vscode-gitlens/issues/4207))
2929
- Fixes detail view incorrectly parses GitHub account in commit message ([#3246](https://github.com/gitkraken/vscode-gitlens/issues/3246))
3030
- Fixes custom instructions are sometimes ignored ([#4267](https://github.com/gitkraken/vscode-gitlens/issues/4267))
31+
- Fixes timed out waiting for authentication provider to register in GitLens after update to version 16.3 ([#4065](https://github.com/gitkraken/vscode-gitlens/issues/4065))
3132

3233
## [17.0.3] - 2025-04-17
3334

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
import { authentication } from 'vscode';
1+
import { authentication, extensions } from 'vscode';
22
import { wrapForForcedInsecureSSL } from '@env/fetch';
33
import type { IntegrationId } from '../../../../constants.integrations';
44
import type { Container } from '../../../../container';
55
import { sequentialize } from '../../../../system/function';
6+
import { Logger } from '../../../../system/logger';
7+
import { getLogScope } from '../../../../system/logger.scope';
68
import type { IntegrationAuthenticationSessionDescriptor } from '../../../integrations/authentication/integrationAuthenticationProvider';
79
import type { ProviderAuthenticationSession } from '../../../integrations/authentication/models';
810

11+
const failedAuthProviderIds = new Set<string>();
12+
913
export const getBuiltInIntegrationSession = sequentialize(
1014
(
1115
container: Container,
@@ -19,18 +23,45 @@ export const getBuiltInIntegrationSession = sequentialize(
1923
wrapForForcedInsecureSSL(
2024
container.integrations.ignoreSSLErrors({ id: id, domain: descriptor.domain }),
2125
async () => {
22-
const session = await authentication.getSession(id, descriptor.scopes, {
23-
createIfNone: options?.createIfNeeded,
24-
silent: options?.silent,
25-
forceNewSession: options?.forceNewSession,
26-
});
27-
if (session == null) return undefined;
26+
if (failedAuthProviderIds.has(id)) return undefined;
27+
28+
const scope = getLogScope();
29+
30+
if (id === 'github') {
31+
const extension = extensions.getExtension('vscode.github-authentication');
32+
if (extension == null) {
33+
failedAuthProviderIds.add(id);
34+
Logger.warn(scope, `Authentication provider '${id}' is not registered; User has disabled it`);
35+
return undefined;
36+
}
37+
}
38+
39+
try {
40+
const session = await authentication.getSession(id, descriptor.scopes, {
41+
createIfNone: options?.createIfNeeded,
42+
silent: options?.silent,
43+
forceNewSession: options?.forceNewSession,
44+
});
45+
if (session == null) return undefined;
46+
47+
return {
48+
...session,
49+
cloud: false,
50+
domain: descriptor.domain,
51+
};
52+
} catch (ex) {
53+
if (typeof ex === 'string' && ex === 'Timed out waiting for authentication provider to register') {
54+
failedAuthProviderIds.add(id);
55+
Logger.warn(
56+
scope,
57+
`Authentication provider '${id}' is not registered; User likely has disabled it`,
58+
);
59+
return undefined;
60+
}
2861

29-
return {
30-
...session,
31-
cloud: false,
32-
domain: descriptor.domain,
33-
};
62+
Logger.error(ex, scope, 'getBuiltInIntegrationSession');
63+
throw ex;
64+
}
3465
},
3566
),
3667
);

src/plus/integrations/authentication/github.ts

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { Disposable, QuickInputButton } from 'vscode';
22
import { authentication, env, ThemeIcon, Uri, window } from 'vscode';
3-
import { wrapForForcedInsecureSSL } from '@env/fetch';
43
import { HostingIntegrationId, SelfHostedIntegrationId } from '../../../constants.integrations';
54
import type { Sources } from '../../../constants.telemetry';
65
import type { Container } from '../../../container';
6+
import { getBuiltInIntegrationSession } from '../../gk/utils/-webview/integrationAuthentication.utils';
77
import type { ConfiguredIntegrationService } from './configuredIntegrationService';
88
import type { IntegrationAuthenticationSessionDescriptor } from './integrationAuthenticationProvider';
99
import {
@@ -33,38 +33,20 @@ export class GitHubAuthenticationProvider extends CloudIntegrationAuthentication
3333
return HostingIntegrationId.GitHub;
3434
}
3535

36-
private async getBuiltInExistingSession(
37-
descriptor: IntegrationAuthenticationSessionDescriptor,
38-
forceNewSession?: boolean,
39-
): Promise<ProviderAuthenticationSession | undefined> {
40-
return wrapForForcedInsecureSSL(
41-
this.container.integrations.ignoreSSLErrors({ id: this.authProviderId, domain: descriptor?.domain }),
42-
async () => {
43-
const session = await authentication.getSession(this.authProviderId, descriptor.scopes, {
44-
forceNewSession: forceNewSession ? true : undefined,
45-
silent: forceNewSession ? undefined : true,
46-
});
47-
if (session == null) return undefined;
48-
return {
49-
...session,
50-
cloud: false,
51-
domain: descriptor.domain,
52-
};
53-
},
54-
);
55-
}
56-
5736
public override async getSession(
5837
descriptor: IntegrationAuthenticationSessionDescriptor,
5938
options?: { createIfNeeded?: boolean; forceNewSession?: boolean; source?: Sources },
6039
): Promise<ProviderAuthenticationSession | undefined> {
61-
let vscodeSession = await this.getBuiltInExistingSession(descriptor);
62-
63-
if (vscodeSession != null && options?.forceNewSession) {
64-
vscodeSession = await this.getBuiltInExistingSession(descriptor, true);
40+
let session = await getBuiltInIntegrationSession(this.container, this.authProviderId, descriptor, {
41+
silent: true,
42+
});
43+
if (session != null && options?.forceNewSession) {
44+
session = await getBuiltInIntegrationSession(this.container, this.authProviderId, descriptor, {
45+
forceNewSession: true,
46+
});
6547
}
6648

67-
if (vscodeSession != null) return vscodeSession;
49+
if (session != null) return session;
6850

6951
return super.getSession(descriptor, options);
7052
}

0 commit comments

Comments
 (0)