Skip to content

Commit 53df269

Browse files
authored
Queue remote extension installation tasks (#19)
1 parent 3de3eb1 commit 53df269

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

gitpod-remote/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "%displayName%",
44
"description": "%description%",
55
"publisher": "gitpod",
6-
"version": "0.0.52",
6+
"version": "0.0.53",
77
"license": "MIT",
88
"preview": true,
99
"icon": "resources/gitpod.png",

gitpod-remote/src/extension.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { tunnelPorts } from './ports';
1010
import { GitpodPortViewProvider } from './portViewProvider';
1111
import { initializeRemoteExtensions, installInitialExtensions, ISyncExtension } from './remoteExtensionInit';
1212

13+
let initialExtensionsInstallPromise: Promise<void>;
1314
let gitpodContext: GitpodExtensionContext | undefined;
1415
export async function activate(context: vscode.ExtensionContext) {
1516
gitpodContext = await setupGitpodContext(context);
@@ -19,7 +20,7 @@ export async function activate(context: vscode.ExtensionContext) {
1920

2021
registerCommands(gitpodContext);
2122
registerTasks(gitpodContext);
22-
installInitialExtensions(gitpodContext);
23+
initialExtensionsInstallPromise = installInitialExtensions(gitpodContext);
2324

2425
const portViewProvider = new GitpodPortViewProvider(gitpodContext);
2526
context.subscriptions.push(vscode.window.registerWebviewViewProvider(GitpodPortViewProvider.viewType, portViewProvider, { webviewOptions: { retainContextWhenHidden: true } }));
@@ -86,5 +87,12 @@ function registerCommands(context: GitpodExtensionContext) {
8687
}));
8788

8889
// Initialize remote extensions
89-
context.subscriptions.push(vscode.commands.registerCommand('__gitpod.initializeRemoteExtensions', (extensions: ISyncExtension[]) => initializeRemoteExtensions(extensions, gitpodContext!)));
90+
context.subscriptions.push(vscode.commands.registerCommand('__gitpod.initializeRemoteExtensions', async (extensions: ISyncExtension[]) => {
91+
try {
92+
// Await for initial extension instalation so we don't have too many extension installations tasks running
93+
await initialExtensionsInstallPromise;
94+
} catch {
95+
}
96+
return initializeRemoteExtensions(extensions, gitpodContext!);
97+
}));
9098
}

gitpod-remote/src/remoteExtensionInit.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ export async function initializeRemoteExtensions(extensions: ISyncExtension[], c
4747
delete execEnv['ELECTRON_RUN_AS_NODE']
4848
try {
4949
context.logger.info('Trying to initialize remote extensions:', extensions.map(e => e.identifier.id).join('\n'));
50-
const { stderr } = await util.promisify(cp.exec)(`${codeCliPath} ${args}`, { env: execEnv });
51-
if (stderr) {
52-
context.logger.error('Failed to initialize remote extensions:', stderr);
53-
}
50+
const { stdout, stderr } = await util.promisify(cp.exec)(`${codeCliPath} ${args}`, { env: execEnv });
51+
context.logger.info(`Initialize remote extensions cli commamnd output:\nstdout: ${stdout}\nstderr: ${stderr}`);
5452
} catch (e) {
5553
context.logger.error('Error trying to initialize remote extensions:', e);
5654
}
@@ -110,10 +108,8 @@ export async function installInitialExtensions(context: GitpodExtensionContext)
110108
delete execEnv['ELECTRON_RUN_AS_NODE']
111109
try {
112110
context.logger.info('Trying to initialize remote extensions from gitpod.yml:', extensions.map(e => e.toString()).join('\n'));
113-
const { stderr } = await util.promisify(cp.exec)(`${codeCliPath} ${args}`, { env: execEnv });
114-
if (stderr) {
115-
context.logger.error('Failed to initialize remote extensions from gitpod.yml:', stderr);
116-
}
111+
const { stdout, stderr } = await util.promisify(cp.exec)(`${codeCliPath} ${args}`, { env: execEnv });
112+
context.logger.info(`Initialize remote extensions cli commamnd output:\nstdout: ${stdout}\nstderr: ${stderr}`);
117113
} catch (e) {
118114
context.logger.error('Error trying to initialize remote extensions from gitpod.yml:', e);
119115
}

0 commit comments

Comments
 (0)