Skip to content

Commit

Permalink
Fixes microsoft#73656: Do not activate extensions if the search for g…
Browse files Browse the repository at this point in the history
…lob patterns from `workspaceContains` times out
  • Loading branch information
alexdima committed Nov 19, 2021
1 parent 39155b5 commit 9fd6ee7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHostExtensionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme

const localWithRemote = !this._initData.remote.isRemote && !!this._initData.remote.authority;
const host: IExtensionActivationHost = {
logService: this._logService,
folders: folders.map(folder => folder.uri),
forceUsingSearch: localWithRemote,
exists: (uri) => this._hostUtils.exists(uri.fsPath),
Expand Down
4 changes: 3 additions & 1 deletion src/vs/workbench/api/common/shared/workspaceContains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiati
import { QueryBuilder } from 'vs/workbench/contrib/search/common/queryBuilder';
import { ISearchService } from 'vs/workbench/services/search/common/search';
import { toWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { ILogService } from 'vs/platform/log/common/log';

const WORKSPACE_CONTAINS_TIMEOUT = 7000;

export interface IExtensionActivationHost {
readonly logService: ILogService;
readonly folders: readonly UriComponents[];
readonly forceUsingSearch: boolean;

Expand Down Expand Up @@ -87,7 +89,7 @@ async function _activateIfGlobPatterns(host: IExtensionActivationHost, extension

const timer = setTimeout(async () => {
tokenSource.cancel();
activate(`workspaceContainsTimeout:${globPatterns.join(',')}`);
host.logService.info(`Not activating extension '${extensionId.value}': Timed out while searching for 'workspaceContains' pattern ${globPatterns.join(',')}`);
}, WORKSPACE_CONTAINS_TIMEOUT);

let exists: boolean = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ export class ExtensionService extends AbstractExtensionService implements IExten
@IExtensionManagementService extensionManagementService: IExtensionManagementService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IConfigurationService configurationService: IConfigurationService,
@IExtensionManifestPropertiesService extensionManifestPropertiesService: IExtensionManifestPropertiesService,
@IWebExtensionsScannerService webExtensionsScannerService: IWebExtensionsScannerService,
@ILogService logService: ILogService,
@IRemoteAuthorityResolverService private readonly _remoteAuthorityResolverService: IRemoteAuthorityResolverService,
@IRemoteAgentService private readonly _remoteAgentService: IRemoteAgentService,
@IWebExtensionsScannerService webExtensionsScannerService: IWebExtensionsScannerService,
@ILifecycleService private readonly _lifecycleService: ILifecycleService,
@IExtensionManifestPropertiesService extensionManifestPropertiesService: IExtensionManifestPropertiesService,
@IUserDataInitializationService private readonly _userDataInitializationService: IUserDataInitializationService,
@ILogService private readonly _logService: ILogService,
) {
super(
instantiationService,
Expand All @@ -67,7 +67,8 @@ export class ExtensionService extends AbstractExtensionService implements IExten
contextService,
configurationService,
extensionManifestPropertiesService,
webExtensionsScannerService
webExtensionsScannerService,
logService
);

this._runningLocation = new Map<string, ExtensionRunningLocation>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
@IConfigurationService protected readonly _configurationService: IConfigurationService,
@IExtensionManifestPropertiesService protected readonly _extensionManifestPropertiesService: IExtensionManifestPropertiesService,
@IWebExtensionsScannerService protected readonly _webExtensionsScannerService: IWebExtensionsScannerService,
@ILogService protected readonly _logService: ILogService,
) {
super();

Expand Down Expand Up @@ -495,6 +496,7 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
const workspace = await this._contextService.getCompleteWorkspace();
const forceUsingSearch = !!this._environmentService.remoteAuthority;
const host: IWorkspaceContainsActivationHost = {
logService: this._logService,
folders: workspace.folders.map(folder => folder.uri),
forceUsingSearch: forceUsingSearch,
exists: (uri) => this._fileService.exists(uri),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,30 @@ export class ExtensionService extends AbstractExtensionService implements IExten
constructor(
@IInstantiationService instantiationService: IInstantiationService,
@INotificationService notificationService: INotificationService,
@IWorkbenchEnvironmentService _environmentService: IWorkbenchEnvironmentService,
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
@ITelemetryService telemetryService: ITelemetryService,
@IWorkbenchExtensionEnablementService extensionEnablementService: IWorkbenchExtensionEnablementService,
@IFileService fileService: IFileService,
@IProductService productService: IProductService,
@IExtensionManagementService extensionManagementService: IExtensionManagementService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IConfigurationService configurationService: IConfigurationService,
@IExtensionManifestPropertiesService extensionManifestPropertiesService: IExtensionManifestPropertiesService,
@IWebExtensionsScannerService webExtensionsScannerService: IWebExtensionsScannerService,
@ILogService logService: ILogService,
@IRemoteAgentService private readonly _remoteAgentService: IRemoteAgentService,
@IRemoteAuthorityResolverService private readonly _remoteAuthorityResolverService: IRemoteAuthorityResolverService,
@ILifecycleService private readonly _lifecycleService: ILifecycleService,
@IWebExtensionsScannerService webExtensionsScannerService: IWebExtensionsScannerService,
@INativeHostService private readonly _nativeHostService: INativeHostService,
@IHostService private readonly _hostService: IHostService,
@IRemoteExplorerService private readonly _remoteExplorerService: IRemoteExplorerService,
@IExtensionGalleryService private readonly _extensionGalleryService: IExtensionGalleryService,
@ILogService private readonly _logService: ILogService,
@IWorkspaceTrustManagementService private readonly _workspaceTrustManagementService: IWorkspaceTrustManagementService,
@IExtensionManifestPropertiesService extensionManifestPropertiesService: IExtensionManifestPropertiesService,
) {
super(
instantiationService,
notificationService,
_environmentService,
environmentService,
telemetryService,
extensionEnablementService,
fileService,
Expand All @@ -89,7 +89,8 @@ export class ExtensionService extends AbstractExtensionService implements IExten
contextService,
configurationService,
extensionManifestPropertiesService,
webExtensionsScannerService
webExtensionsScannerService,
logService
);

[this._enableLocalWebWorker, this._lazyLocalWebWorker] = this._isLocalWebWorkerEnabled();
Expand Down

0 comments on commit 9fd6ee7

Please sign in to comment.