From edc319a90ce2e1e5ed522bba6daa93ea02b89980 Mon Sep 17 00:00:00 2001 From: Kim Santiago <31145923+kisantia@users.noreply.github.com> Date: Fri, 25 Jun 2021 15:46:28 -0700 Subject: [PATCH] Remove awaits that were blocking data workspace extension from loading (#15904) * remove awaits that were blocking data workspace extension from loading * add comment * remove await and use then * use return instead of await * add notification when there's an error --- extensions/data-workspace/src/main.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/extensions/data-workspace/src/main.ts b/extensions/data-workspace/src/main.ts index 2736cdbc66..c872169816 100644 --- a/extensions/data-workspace/src/main.ts +++ b/extensions/data-workspace/src/main.ts @@ -18,10 +18,18 @@ import { createNewProjectWithQuickpick } from './dialogs/newProjectQuickpick'; export async function activate(context: vscode.ExtensionContext): Promise { const workspaceService = new WorkspaceService(context); - await workspaceService.loadTempProjects(); - workspaceService.checkForProjectsNotAddedToWorkspace(); - context.subscriptions.push(vscode.workspace.onDidChangeWorkspaceFolders(async () => { - await workspaceService.checkForProjectsNotAddedToWorkspace(); + + // this is not being awaited to not block the rest of activate function from running while loading any temp projects and + // checking for projects not added to the workspace yet + workspaceService.loadTempProjects().then(() => { + return workspaceService.checkForProjectsNotAddedToWorkspace(); + }).catch(error => { + console.error(error); + vscode.window.showErrorMessage(error instanceof Error ? error.message : error); + }); + + context.subscriptions.push(vscode.workspace.onDidChangeWorkspaceFolders(() => { + workspaceService.checkForProjectsNotAddedToWorkspace(); })); const workspaceTreeDataProvider = new WorkspaceTreeDataProvider(workspaceService);