SQL-Migration extension - fix refresh reentrancy hang (#16482)

* Fix application hang on refresh

* fix re-entrancy issue with refresh

* adding additional refresh checking
This commit is contained in:
brian-harris
2021-07-29 16:44:56 -07:00
committed by GitHub
parent 251d250523
commit e3c7e06983
4 changed files with 49 additions and 22 deletions

View File

@@ -49,6 +49,8 @@ export class DashboardWidget {
private _autoRefreshHandle!: NodeJS.Timeout;
private _disposables: vscode.Disposable[] = [];
private isRefreshing: boolean = false;
constructor() {
}
@@ -242,14 +244,19 @@ export class DashboardWidget {
}
private setAutoRefresh(interval: SupportedAutoRefreshIntervals): void {
let classVariable = this;
const classVariable = this;
clearInterval(this._autoRefreshHandle);
if (interval !== -1) {
this._autoRefreshHandle = setInterval(function () { classVariable.refreshMigrations(); }, interval);
this._autoRefreshHandle = setInterval(async function () { await classVariable.refreshMigrations(); }, interval);
}
}
private async refreshMigrations(): Promise<void> {
if (this.isRefreshing) {
return;
}
this.isRefreshing = true;
this._viewAllMigrationsButton.enabled = false;
this._migrationStatusCardLoadingContainer.loading = true;
try {
@@ -304,6 +311,7 @@ export class DashboardWidget {
} catch (error) {
console.log(error);
} finally {
this.isRefreshing = false;
this._migrationStatusCardLoadingContainer.loading = false;
this._viewAllMigrationsButton.enabled = true;
}