From 47798cc1548440cd2de2238a59bd938e9aaad931 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Fri, 16 Dec 2022 17:31:58 -0500 Subject: [PATCH] Fixes #2318 avoids sign out in more cases --- CHANGELOG.md | 2 ++ src/plus/subscription/subscriptionService.ts | 33 +++++++++++++++++++--------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9454194..0a749b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,10 +24,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Holding the `ctrl` key with a commit row selected will highlight rows for that commit's branch ### Changed + - In the _Commit Graph_, increases the time to highlight associated rows when hovering over a branch to 1s ### Fixed +- Fixes [#2318](https://github.com/gitkraken/vscode-gitlens/issues/2318) - GitLens need to login again after VS Code insiders upgrade every day - Fixes [#2377](https://github.com/gitkraken/vscode-gitlens/issues/2377) - Missing Azure Devops Icon - Fixes [#2380](https://github.com/gitkraken/vscode-gitlens/issues/2380) - Autolink fails with curly braces - Fixes [#2381](https://github.com/gitkraken/vscode-gitlens/issues/2381) - can't use scrollbar in 'Commit Graph' view diff --git a/src/plus/subscription/subscriptionService.ts b/src/plus/subscription/subscriptionService.ts index 8cde3d7..62ad6dd 100644 --- a/src/plus/subscription/subscriptionService.ts +++ b/src/plus/subscription/subscriptionService.ts @@ -754,16 +754,29 @@ export class SubscriptionService implements Disposable { Logger.error(ex, scope); debugger; + this.container.telemetry.sendEvent('account/validation/failed', { + 'account.id': session.account.id, + exception: String(ex), + code: ex.original?.code, + statusCode: ex.statusCode, + }); + + Logger.debug(scope, `Account validation failed (${ex.statusCode ?? ex.original?.code})`); + if (ex instanceof AccountValidationError) { const name = session.account.label; + // if ( + // (ex.statusCode != null && ex.statusCode < 500) || + // (ex.statusCode == null && (ex.original as any)?.code !== 'ENOTFOUND') + // ) { if ( - (ex.statusCode != null && ex.statusCode < 500) || - (ex.statusCode == null && (ex.original as any)?.code !== 'ENOTFOUND') + (ex.original as any)?.code !== 'ENOTFOUND' && + ex.statusCode != null && + ex.statusCode < 500 && + ex.statusCode >= 400 ) { session = null; - - Logger.debug(scope, `Account validation failed (${ex.statusCode ?? (ex.original as any)?.code})`); await this.logoutCore(); if (createIfNeeded) { @@ -785,12 +798,12 @@ export class SubscriptionService implements Disposable { } else { 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', - ); - } + // 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', + // ); + // } } } }