Skip to content

Commit f537aa8

Browse files
test new approach
Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
1 parent 30fe6ee commit f537aa8

4 files changed

Lines changed: 11 additions & 114 deletions

File tree

code/src/vs/server/node/che/defaultExtensionsInstaller.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class DefaultExtensionsInstaller extends Disposable {
2727
private readonly userDataProfilesService: IUserDataProfilesService,
2828
) {
2929
super();
30+
this.logService.info(`!!!!!!!! DefaultExtensionsInstaller: Constructor`);
3031
this.initialize().catch(error => {
3132
this.logService.error('Failed to initialize default extensions installer', error);
3233
});

code/src/vs/server/node/serverServices.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,15 @@ export async function setupServerServices(connectionToken: ServerConnectionToken
276276
// clean up extensions folder
277277
remoteExtensionsScanner.whenExtensionsReady().then(() => extensionManagementService.cleanUp());
278278

279-
// Install default extensions from DEFAULT_EXTENSIONS environment variable
280-
disposables.add(new DefaultExtensionsInstaller(extensionManagementService, logService, fileService, userDataProfilesService));
279+
// Install default extensions from DEFAULT_EXTENSIONS_NEW environment variable
280+
// Wait for extensions to be ready before installing to avoid race conditions where
281+
// extensions try to activate before their dependencies are fully installed
282+
remoteExtensionsScanner.whenExtensionsReady().then(() => {
283+
logService.info('DefaultExtensionsInstaller: Extensions are ready, starting default extensions installation');
284+
disposables.add(new DefaultExtensionsInstaller(extensionManagementService, logService, fileService, userDataProfilesService));
285+
}).catch(error => {
286+
logService.error('DefaultExtensionsInstaller: Failed to wait for extensions ready', error);
287+
});
281288

282289
disposables.add(new ErrorTelemetry(accessor.get(ITelemetryService)));
283290

code/src/vs/workbench/contrib/extensions/browser/extensions.contribution.ts

Lines changed: 1 addition & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import { InstantiationType, registerSingleton } from '../../../../platform/insta
3535
import { IInstantiationService, ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js';
3636
import * as jsonContributionRegistry from '../../../../platform/jsonschemas/common/jsonContributionRegistry.js';
3737
import { INotificationService, Severity } from '../../../../platform/notification/common/notification.js';
38-
import { ILogService } from '../../../../platform/log/common/log.js';
3938
import product from '../../../../platform/product/common/product.js';
4039
import { IProductService } from '../../../../platform/product/common/productService.js';
4140
import { ProgressLocation } from '../../../../platform/progress/common/progress.js';
@@ -66,7 +65,7 @@ import { ILanguageModelToolsService } from '../../chat/common/languageModelTools
6665
import { CONTEXT_KEYBINDINGS_EDITOR } from '../../preferences/common/preferences.js';
6766
import { IWebview } from '../../webview/browser/webview.js';
6867
import { Query } from '../common/extensionQuery.js';
69-
import { AutoRestartConfigurationKey, AutoUpdateConfigurationKey, CONTEXT_EXTENSIONS_GALLERY_STATUS, CONTEXT_HAS_GALLERY, DefaultViewsContext, ExtensionEditorTab, ExtensionRuntimeActionType, EXTENSIONS_CATEGORY, extensionsFilterSubMenu, extensionsSearchActionsMenu, HasOutdatedExtensionsContext, IExtensionArg, IExtensionsViewPaneContainer, IExtensionsWorkbenchService, INSTALL_ACTIONS_GROUP, INSTALL_EXTENSION_FROM_VSIX_COMMAND_ID, INSTALL_DEFAULT_EXTENSIONS_COMMAND_ID, IWorkspaceRecommendedExtensionsView, LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID, OUTDATED_EXTENSIONS_VIEW_ID, SELECT_INSTALL_VSIX_EXTENSION_COMMAND_ID, THEME_ACTIONS_GROUP, TOGGLE_IGNORE_EXTENSION_ACTION_ID, UPDATE_ACTIONS_GROUP, VIEWLET_ID, WORKSPACE_RECOMMENDATIONS_VIEW_ID } from '../common/extensions.js';
68+
import { AutoRestartConfigurationKey, AutoUpdateConfigurationKey, CONTEXT_EXTENSIONS_GALLERY_STATUS, CONTEXT_HAS_GALLERY, DefaultViewsContext, ExtensionEditorTab, ExtensionRuntimeActionType, EXTENSIONS_CATEGORY, extensionsFilterSubMenu, extensionsSearchActionsMenu, HasOutdatedExtensionsContext, IExtensionArg, IExtensionsViewPaneContainer, IExtensionsWorkbenchService, INSTALL_ACTIONS_GROUP, INSTALL_EXTENSION_FROM_VSIX_COMMAND_ID, IWorkspaceRecommendedExtensionsView, LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID, OUTDATED_EXTENSIONS_VIEW_ID, SELECT_INSTALL_VSIX_EXTENSION_COMMAND_ID, THEME_ACTIONS_GROUP, TOGGLE_IGNORE_EXTENSION_ACTION_ID, UPDATE_ACTIONS_GROUP, VIEWLET_ID, WORKSPACE_RECOMMENDATIONS_VIEW_ID } from '../common/extensions.js';
7069
import { ExtensionsConfigurationSchema, ExtensionsConfigurationSchemaId } from '../common/extensionsFileTemplate.js';
7170
import { ExtensionsInput } from '../common/extensionsInput.js';
7271
import { KeymapExtensions } from '../common/extensionsUtils.js';
@@ -926,115 +925,6 @@ class ExtensionsContributions extends Disposable implements IWorkbenchContributi
926925
}
927926
});
928927

929-
this.registerExtensionAction({
930-
id: INSTALL_DEFAULT_EXTENSIONS_COMMAND_ID,
931-
title: localize('installDefaultExtensions', "Install Default Extensions"),
932-
run: async (accessor: ServicesAccessor) => {
933-
const extensionsWorkbenchService = accessor.get(IExtensionsWorkbenchService);
934-
const hostService = accessor.get(IHostService);
935-
const notificationService = accessor.get(INotificationService);
936-
const logService = accessor.get(ILogService);
937-
logService.info('++++ !!!!!!!! InstallDefaultExtensions');
938-
939-
// Read extension paths from environment variable
940-
// Use DEFAULT_EXTENSIONS_NEW to match the server-side installer
941-
const defaultExtensionsEnv = typeof process !== 'undefined' && process.env ? process.env['DEFAULT_EXTENSIONS_NEW'] : undefined;
942-
logService.info('++++ !!!!!!!! InstallDefaultExtensions +++ defaultExtensionsEnv ', defaultExtensionsEnv);
943-
if (!defaultExtensionsEnv) {
944-
logService.info('InstallDefaultExtensions: DEFAULT_EXTENSIONS_NEW environment variable not set');
945-
notificationService.info(localize('noDefaultExtensions', "No default extensions to install. DEFAULT_EXTENSIONS_NEW environment variable is not set."));
946-
return;
947-
} else {
948-
logService.info('++++ !!!!!!!! InstallDefaultExtensions +++ EXIST defaultExtensionsEnv ', defaultExtensionsEnv);
949-
}
950-
951-
const extensionPaths = defaultExtensionsEnv.split(';').filter(p => p.trim());
952-
if (extensionPaths.length === 0) {
953-
logService.info('InstallDefaultExtensions: No extensions to install');
954-
notificationService.info(localize('noDefaultExtensionsPaths', "No default extensions to install."));
955-
return;
956-
}
957-
958-
logService.info(`InstallDefaultExtensions: Installing ${extensionPaths.length} default extension(s) from environment variable`);
959-
960-
// Convert paths to URIs
961-
const vsixs = extensionPaths
962-
.filter(p => p.trim())
963-
.map(p => URI.file(p.trim()));
964-
965-
if (vsixs.length === 0) {
966-
return;
967-
}
968-
969-
// Install all extensions in parallel (same as installFromVSIX command)
970-
const result = await Promise.allSettled(vsixs.map(async (vsix) => {
971-
logService.info(`InstallDefaultExtensions: Installing extension from ${vsix.fsPath}`);
972-
return await extensionsWorkbenchService.install(vsix, { installGivenVersion: true });
973-
}));
974-
975-
let error: Error | undefined, requireReload = false, requireRestart = false;
976-
const successful: number[] = [];
977-
const failed: number[] = [];
978-
979-
for (let i = 0; i < result.length; i++) {
980-
const r = result[i];
981-
if (r.status === 'rejected') {
982-
failed.push(i);
983-
logService.error(`InstallDefaultExtensions: Failed to install extension from ${vsixs[i].fsPath}`, r.reason);
984-
if (!error) {
985-
error = new Error(r.reason);
986-
}
987-
} else {
988-
successful.push(i);
989-
requireReload = requireReload || r.value.runtimeState?.action === ExtensionRuntimeActionType.ReloadWindow;
990-
requireRestart = requireRestart || r.value.runtimeState?.action === ExtensionRuntimeActionType.RestartExtensions;
991-
}
992-
}
993-
994-
if (error && successful.length === 0) {
995-
// All failed
996-
notificationService.error(localize('installDefaultExtensionsFailed', "Failed to install default extensions: {0}", error.message));
997-
return;
998-
}
999-
1000-
if (failed.length > 0) {
1001-
// Some failed
1002-
notificationService.warn(localize('installDefaultExtensionsPartial', "Installed {0} of {1} default extensions. {2} failed.", successful.length, vsixs.length, failed.length));
1003-
}
1004-
1005-
if (requireReload) {
1006-
notificationService.prompt(
1007-
Severity.Info,
1008-
successful.length > 1 ? localize('InstallDefaultExtensions.successReload', "Completed installing {0} default extensions. Please reload Visual Studio Code to enable them.", successful.length)
1009-
: localize('InstallDefaultExtension.successReload', "Completed installing default extension. Please reload Visual Studio Code to enable it."),
1010-
[{
1011-
label: localize('InstallVSIXAction.reloadNow', "Reload Now"),
1012-
run: () => hostService.reload()
1013-
}]
1014-
);
1015-
}
1016-
else if (requireRestart) {
1017-
notificationService.prompt(
1018-
Severity.Info,
1019-
successful.length > 1 ? localize('InstallDefaultExtensions.successRestart', "Completed installing {0} default extensions. Please restart extensions to enable them.", successful.length)
1020-
: localize('InstallDefaultExtension.successRestart', "Completed installing default extension. Please restart extensions to enable it."),
1021-
[{
1022-
label: localize('InstallVSIXAction.restartExtensions', "Restart Extensions"),
1023-
run: () => extensionsWorkbenchService.updateRunningExtensions()
1024-
}]
1025-
);
1026-
}
1027-
else if (successful.length > 0) {
1028-
notificationService.prompt(
1029-
Severity.Info,
1030-
successful.length > 1 ? localize('InstallDefaultExtensions.successNoReload', "Completed installing {0} default extensions.", successful.length)
1031-
: localize('InstallDefaultExtension.successNoReload', "Completed installing default extension."),
1032-
[]
1033-
);
1034-
}
1035-
}
1036-
});
1037-
1038928
this.registerExtensionAction({
1039929
id: 'workbench.extensions.action.installExtensionFromLocation',
1040930
title: localize2('installExtensionFromLocation', 'Install Extension from Location...'),

code/src/vs/workbench/contrib/extensions/common/extensions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ export const OUTDATED_EXTENSIONS_VIEW_ID = 'workbench.views.extensions.searchOut
248248
export const TOGGLE_IGNORE_EXTENSION_ACTION_ID = 'workbench.extensions.action.toggleIgnoreExtension';
249249
export const SELECT_INSTALL_VSIX_EXTENSION_COMMAND_ID = 'workbench.extensions.action.installVSIX';
250250
export const INSTALL_EXTENSION_FROM_VSIX_COMMAND_ID = 'workbench.extensions.command.installFromVSIX';
251-
export const INSTALL_DEFAULT_EXTENSIONS_COMMAND_ID = 'workbench.extensions.command.installDefaultExtensions';
252251

253252
export const LIST_WORKSPACE_UNSUPPORTED_EXTENSIONS_COMMAND_ID = 'workbench.extensions.action.listWorkspaceUnsupportedExtensions';
254253

0 commit comments

Comments
 (0)