ensureNoDisposablesAreLeakedInTestSuite: ipc (#192570)

* ensureNoDisposablesAreLeakedInTestSuite: ipc

related to #190503

* debt - proxy services need to ask for disposables

---------

Co-authored-by: Benjamin Pasero <benjamin.pasero@microsoft.com>
This commit is contained in:
João Moreno
2023-09-11 21:01:46 +02:00
committed by GitHub
co-authored by Benjamin Pasero
parent be6c6b7d3c
commit 39de20e8a3
7 changed files with 118 additions and 84 deletions
+20 -18
View File
@@ -14,7 +14,7 @@ import { isEqualOrParent } from 'vs/base/common/extpath';
import { once } from 'vs/base/common/functional';
import { stripComments } from 'vs/base/common/json';
import { getPathLabel } from 'vs/base/common/labels';
import { Disposable } from 'vs/base/common/lifecycle';
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
import { Schemas } from 'vs/base/common/network';
import { isAbsolute, join, posix } from 'vs/base/common/path';
import { IProcessEnvironment, isLinux, isLinuxSnap, isMacintosh, isWindows, OS } from 'vs/base/common/platform';
@@ -1051,10 +1051,12 @@ export class CodeApplication extends Disposable {
// can talk to the first instance. Electron IPC does not work
// across apps until `requestSingleInstance` APIs are adopted.
const launchChannel = ProxyChannel.fromService(accessor.get(ILaunchMainService), { disableMarshalling: true });
const disposables = this._register(new DisposableStore());
const launchChannel = ProxyChannel.fromService(accessor.get(ILaunchMainService), disposables, { disableMarshalling: true });
this.mainProcessNodeIpcServer.registerChannel('launch', launchChannel);
const diagnosticsChannel = ProxyChannel.fromService(accessor.get(IDiagnosticsMainService), { disableMarshalling: true });
const diagnosticsChannel = ProxyChannel.fromService(accessor.get(IDiagnosticsMainService), disposables, { disableMarshalling: true });
this.mainProcessNodeIpcServer.registerChannel('diagnostics', diagnosticsChannel);
// Policies (main & shared process)
@@ -1070,7 +1072,7 @@ export class CodeApplication extends Disposable {
sharedProcessClient.then(client => client.registerChannel(LOCAL_FILE_SYSTEM_CHANNEL_NAME, fileSystemProviderChannel));
// User Data Profiles
const userDataProfilesService = ProxyChannel.fromService(accessor.get(IUserDataProfilesMainService));
const userDataProfilesService = ProxyChannel.fromService(accessor.get(IUserDataProfilesMainService), disposables);
mainProcessElectronServer.registerChannel('userDataProfiles', userDataProfilesService);
sharedProcessClient.then(client => client.registerChannel('userDataProfiles', userDataProfilesService));
@@ -1083,45 +1085,45 @@ export class CodeApplication extends Disposable {
mainProcessElectronServer.registerChannel('update', updateChannel);
// Issues
const issueChannel = ProxyChannel.fromService(accessor.get(IIssueMainService));
const issueChannel = ProxyChannel.fromService(accessor.get(IIssueMainService), disposables);
mainProcessElectronServer.registerChannel('issue', issueChannel);
// Encryption
const encryptionChannel = ProxyChannel.fromService(accessor.get(IEncryptionMainService));
const encryptionChannel = ProxyChannel.fromService(accessor.get(IEncryptionMainService), disposables);
mainProcessElectronServer.registerChannel('encryption', encryptionChannel);
// Signing
const signChannel = ProxyChannel.fromService(accessor.get(ISignService));
const signChannel = ProxyChannel.fromService(accessor.get(ISignService), disposables);
mainProcessElectronServer.registerChannel('sign', signChannel);
// Keyboard Layout
const keyboardLayoutChannel = ProxyChannel.fromService(accessor.get(IKeyboardLayoutMainService));
const keyboardLayoutChannel = ProxyChannel.fromService(accessor.get(IKeyboardLayoutMainService), disposables);
mainProcessElectronServer.registerChannel('keyboardLayout', keyboardLayoutChannel);
// Native host (main & shared process)
this.nativeHostMainService = accessor.get(INativeHostMainService);
const nativeHostChannel = ProxyChannel.fromService(this.nativeHostMainService);
const nativeHostChannel = ProxyChannel.fromService(this.nativeHostMainService, disposables);
mainProcessElectronServer.registerChannel('nativeHost', nativeHostChannel);
sharedProcessClient.then(client => client.registerChannel('nativeHost', nativeHostChannel));
// Workspaces
const workspacesChannel = ProxyChannel.fromService(accessor.get(IWorkspacesService));
const workspacesChannel = ProxyChannel.fromService(accessor.get(IWorkspacesService), disposables);
mainProcessElectronServer.registerChannel('workspaces', workspacesChannel);
// Menubar
const menubarChannel = ProxyChannel.fromService(accessor.get(IMenubarMainService));
const menubarChannel = ProxyChannel.fromService(accessor.get(IMenubarMainService), disposables);
mainProcessElectronServer.registerChannel('menubar', menubarChannel);
// URL handling
const urlChannel = ProxyChannel.fromService(accessor.get(IURLService));
const urlChannel = ProxyChannel.fromService(accessor.get(IURLService), disposables);
mainProcessElectronServer.registerChannel('url', urlChannel);
// Extension URL Trust
const extensionUrlTrustChannel = ProxyChannel.fromService(accessor.get(IExtensionUrlTrustService));
const extensionUrlTrustChannel = ProxyChannel.fromService(accessor.get(IExtensionUrlTrustService), disposables);
mainProcessElectronServer.registerChannel('extensionUrlTrust', extensionUrlTrustChannel);
// Webview Manager
const webviewChannel = ProxyChannel.fromService(accessor.get(IWebviewManagerService));
const webviewChannel = ProxyChannel.fromService(accessor.get(IWebviewManagerService), disposables);
mainProcessElectronServer.registerChannel('webview', webviewChannel);
// Storage (main & shared process)
@@ -1134,11 +1136,11 @@ export class CodeApplication extends Disposable {
sharedProcessClient.then(client => client.registerChannel('profileStorageListener', profileStorageListener));
// Terminal
const ptyHostChannel = ProxyChannel.fromService(accessor.get(ILocalPtyService));
const ptyHostChannel = ProxyChannel.fromService(accessor.get(ILocalPtyService), disposables);
mainProcessElectronServer.registerChannel(TerminalIpcChannels.LocalPty, ptyHostChannel);
// External Terminal
const externalTerminalChannel = ProxyChannel.fromService(accessor.get(IExternalTerminalMainService));
const externalTerminalChannel = ProxyChannel.fromService(accessor.get(IExternalTerminalMainService), disposables);
mainProcessElectronServer.registerChannel('externalTerminal', externalTerminalChannel);
// Logger
@@ -1151,11 +1153,11 @@ export class CodeApplication extends Disposable {
mainProcessElectronServer.registerChannel('extensionhostdebugservice', electronExtensionHostDebugBroadcastChannel);
// Extension Host Starter
const extensionHostStarterChannel = ProxyChannel.fromService(accessor.get(IExtensionHostStarter));
const extensionHostStarterChannel = ProxyChannel.fromService(accessor.get(IExtensionHostStarter), disposables);
mainProcessElectronServer.registerChannel(ipcExtensionHostStarterChannelName, extensionHostStarterChannel);
// Utility Process Worker
const utilityProcessWorkerChannel = ProxyChannel.fromService(accessor.get(IUtilityProcessWorkerMainService));
const utilityProcessWorkerChannel = ProxyChannel.fromService(accessor.get(IUtilityProcessWorkerMainService), disposables);
mainProcessElectronServer.registerChannel(ipcUtilityProcessWorkerChannelName, utilityProcessWorkerChannel);
}
@@ -7,7 +7,7 @@ import { hostname, release } from 'os';
import { MessagePortMain, MessageEvent } from 'vs/base/parts/sandbox/node/electronTypes';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { onUnexpectedError, setUnexpectedErrorHandler } from 'vs/base/common/errors';
import { combinedDisposable, Disposable, toDisposable } from 'vs/base/common/lifecycle';
import { combinedDisposable, Disposable, DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
import { Schemas } from 'vs/base/common/network';
import { URI } from 'vs/base/common/uri';
import { firstOrDefault } from 'vs/base/common/arrays';
@@ -367,16 +367,18 @@ class SharedProcessMain extends Disposable implements IClientConnectionFilter {
private initChannels(accessor: ServicesAccessor): void {
const disposables = this._register(new DisposableStore());
// Extensions Management
const channel = new ExtensionManagementChannel(accessor.get(IExtensionManagementService), () => null);
this.server.registerChannel('extensions', channel);
// Language Packs
const languagePacksChannel = ProxyChannel.fromService(accessor.get(ILanguagePackService));
const languagePacksChannel = ProxyChannel.fromService(accessor.get(ILanguagePackService), disposables);
this.server.registerChannel('languagePacks', languagePacksChannel);
// Diagnostics
const diagnosticsChannel = ProxyChannel.fromService(accessor.get(IDiagnosticsService));
const diagnosticsChannel = ProxyChannel.fromService(accessor.get(IDiagnosticsService), disposables);
this.server.registerChannel('diagnostics', diagnosticsChannel);
// Extension Tips
@@ -384,11 +386,11 @@ class SharedProcessMain extends Disposable implements IClientConnectionFilter {
this.server.registerChannel('extensionTipsService', extensionTipsChannel);
// Checksum
const checksumChannel = ProxyChannel.fromService(accessor.get(IChecksumService));
const checksumChannel = ProxyChannel.fromService(accessor.get(IChecksumService), disposables);
this.server.registerChannel('checksum', checksumChannel);
// Profiling
const profilingChannel = ProxyChannel.fromService(accessor.get(IV8InspectProfilingService));
const profilingChannel = ProxyChannel.fromService(accessor.get(IV8InspectProfilingService), disposables);
this.server.registerChannel('v8InspectProfiling', profilingChannel);
// Settings Sync
@@ -396,7 +398,7 @@ class SharedProcessMain extends Disposable implements IClientConnectionFilter {
this.server.registerChannel('userDataSyncMachines', userDataSyncMachineChannel);
// Custom Endpoint Telemetry
const customEndpointTelemetryChannel = ProxyChannel.fromService(accessor.get(ICustomEndpointTelemetryService));
const customEndpointTelemetryChannel = ProxyChannel.fromService(accessor.get(ICustomEndpointTelemetryService), disposables);
this.server.registerChannel('customEndpointTelemetry', customEndpointTelemetryChannel);
const userDataSyncAccountChannel = new UserDataSyncAccountServiceChannel(accessor.get(IUserDataSyncAccountService));
@@ -413,11 +415,11 @@ class SharedProcessMain extends Disposable implements IClientConnectionFilter {
this.server.registerChannel('userDataAutoSync', userDataAutoSyncChannel);
// Tunnel
const sharedProcessTunnelChannel = ProxyChannel.fromService(accessor.get(ISharedProcessTunnelService));
const sharedProcessTunnelChannel = ProxyChannel.fromService(accessor.get(ISharedProcessTunnelService), disposables);
this.server.registerChannel(ipcSharedProcessTunnelChannelName, sharedProcessTunnelChannel);
// Remote Tunnel
const remoteTunnelChannel = ProxyChannel.fromService(accessor.get(IRemoteTunnelService));
const remoteTunnelChannel = ProxyChannel.fromService(accessor.get(IRemoteTunnelService), disposables);
this.server.registerChannel('remoteTunnel', remoteTunnelChannel);
}