Browse Source

Fixes #2017 avoids sign out on network errors

main
Eric Amodio 2 years ago
parent
commit
ab19c5c924
3 changed files with 25 additions and 10 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +22
    -8
      src/plus/subscription/subscriptionService.ts
  3. +2
    -2
      src/webviews/home/homeWebviewView.ts

+ 1
- 0
CHANGELOG.md View File

@ -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

+ 22
- 8
src/plus/subscription/subscriptionService.ts View File

@ -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',
);
}
}
}
}

+ 2
- 2
src/webviews/home/homeWebviewView.ts View File

@ -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[] {

Loading…
Cancel
Save