diff --git a/CHANGELOG.md b/CHANGELOG.md index f359c16..958ed3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Fixed +- Fixes [#2017](https://github.com/gitkraken/vscode-gitlens/issues/2017) - Gitlens+ pro keeps signing out - Fixes [#1935](https://github.com/gitkraken/vscode-gitlens/issues/1935) - Constant prompt "Your github credentials do not have the required access" - Fixes [#2067](https://github.com/gitkraken/vscode-gitlens/issues/2067) - Your 'github' credentials are either invalid or expired - Fixes [#2167](https://github.com/gitkraken/vscode-gitlens/issues/2167) - Rollup diff between working tree and fetched remote doesn't show changes diff --git a/src/plus/subscription/subscriptionService.ts b/src/plus/subscription/subscriptionService.ts index 48b7e92..2c31712 100644 --- a/src/plus/subscription/subscriptionService.ts +++ b/src/plus/subscription/subscriptionService.ts @@ -676,6 +676,7 @@ export class SubscriptionService implements Disposable { session = null; if (ex instanceof Error && ex.message.includes('User did not consent')) { + Logger.debug(scope, 'User declined authentication; logging out...'); await this.logout(); return null; } @@ -689,6 +690,7 @@ export class SubscriptionService implements Disposable { } if (session == null) { + Logger.debug(scope, 'No valid session was found; logging out...'); await this.logout(); return session ?? null; } @@ -699,11 +701,19 @@ export class SubscriptionService implements Disposable { Logger.error(ex, scope); debugger; - const name = session.account.label; - session = null; - if (ex instanceof AccountValidationError) { - if (ex.statusCode == null || ex.statusCode < 500) { + const name = session.account.label; + + if ( + (ex.statusCode != null && ex.statusCode < 500) || + (ex.statusCode == null && (ex.original as any)?.code !== 'ENOTFOUND') + ) { + session = null; + + Logger.debug( + scope, + `Account validation failed (${ex.statusCode ?? (ex.original as any)?.code}); logging out...`, + ); await this.logout(); if (createIfNeeded) { @@ -723,10 +733,14 @@ export class SubscriptionService implements Disposable { }); } } else { - void window.showErrorMessage( - `Unable to sign in to your (${name}) GitLens+ account right now. Please try again in a few minutes. If this issue persists, please contact support. Error=${ex.message}`, - 'OK', - ); + session = session ?? null; + + if ((ex.original as any)?.code !== 'ENOTFOUND') { + void window.showErrorMessage( + `Unable to sign in to your (${name}) GitLens+ account right now. Please try again in a few minutes. If this issue persists, please contact support. Error=${ex.message}`, + 'OK', + ); + } } } } diff --git a/src/webviews/home/homeWebviewView.ts b/src/webviews/home/homeWebviewView.ts index 1dd3258..a15edf1 100644 --- a/src/webviews/home/homeWebviewView.ts +++ b/src/webviews/home/homeWebviewView.ts @@ -29,13 +29,13 @@ export class HomeWebviewView extends WebviewViewBase { protected override onVisibilityChanged(visible: boolean): void { if (!visible) return; - void this.validateSubscription(); + queueMicrotask(() => void this.validateSubscription()); } protected override onWindowFocusChanged(focused: boolean): void { if (!focused) return; - void this.validateSubscription(); + queueMicrotask(() => void this.validateSubscription()); } protected override registerCommands(): Disposable[] {