diff --git a/build/lib/layersChecker.js b/build/lib/layersChecker.js index c83d6fcf984..8caccef815e 100644 --- a/build/lib/layersChecker.js +++ b/build/lib/layersChecker.js @@ -191,9 +191,6 @@ const RULES = [ 'Event', 'Request' ], - disallowedTypes: [ - 'ipcMain' // not allowed, use validatedIpcMain instead - ], disallowedDefinitions: [ 'lib.dom.d.ts' // no DOM ] diff --git a/build/lib/layersChecker.ts b/build/lib/layersChecker.ts index 95810c3b5f4..af9ccd0ae92 100644 --- a/build/lib/layersChecker.ts +++ b/build/lib/layersChecker.ts @@ -69,7 +69,7 @@ const NATIVE_TYPES = [ 'ICommonNativeHostService' ]; -const RULES: IRule[] = [ +const RULES = [ // Tests: skip { @@ -210,9 +210,6 @@ const RULES: IRule[] = [ 'Event', 'Request' ], - disallowedTypes: [ - 'ipcMain' // not allowed, use validatedIpcMain instead - ], disallowedDefinitions: [ 'lib.dom.d.ts' // no DOM ] diff --git a/src/vs/base/parts/contextmenu/electron-main/contextmenu.ts b/src/vs/base/parts/contextmenu/electron-main/contextmenu.ts index 6b2eb1cb820..fa64089c460 100644 --- a/src/vs/base/parts/contextmenu/electron-main/contextmenu.ts +++ b/src/vs/base/parts/contextmenu/electron-main/contextmenu.ts @@ -3,13 +3,12 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { BrowserWindow, IpcMainEvent, Menu, MenuItem } from 'electron'; -import { validatedIpcMain } from 'vs/base/parts/ipc/electron-main/ipcMain'; +import { BrowserWindow, ipcMain, IpcMainEvent, Menu, MenuItem } from 'electron'; import { withNullAsUndefined } from 'vs/base/common/types'; import { CONTEXT_MENU_CHANNEL, CONTEXT_MENU_CLOSE_CHANNEL, IPopupOptions, ISerializableContextMenuItem } from 'vs/base/parts/contextmenu/common/contextmenu'; export function registerContextMenuListener(): void { - validatedIpcMain.on(CONTEXT_MENU_CHANNEL, (event: IpcMainEvent, contextMenuId: number, items: ISerializableContextMenuItem[], onClickChannel: string, options?: IPopupOptions) => { + ipcMain.on(CONTEXT_MENU_CHANNEL, (event: IpcMainEvent, contextMenuId: number, items: ISerializableContextMenuItem[], onClickChannel: string, options?: IPopupOptions) => { const menu = createMenu(event, onClickChannel, items); menu.popup({ diff --git a/src/vs/base/parts/ipc/electron-main/ipc.electron.ts b/src/vs/base/parts/ipc/electron-main/ipc.electron.ts index f0d395c4bfa..431c44bf3d1 100644 --- a/src/vs/base/parts/ipc/electron-main/ipc.electron.ts +++ b/src/vs/base/parts/ipc/electron-main/ipc.electron.ts @@ -3,8 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { WebContents } from 'electron'; -import { validatedIpcMain } from 'vs/base/parts/ipc/electron-main/ipcMain'; +import { ipcMain, WebContents } from 'electron'; import { VSBuffer } from 'vs/base/common/buffer'; import { Emitter, Event } from 'vs/base/common/event'; import { IDisposable, toDisposable } from 'vs/base/common/lifecycle'; @@ -17,7 +16,7 @@ interface IIPCEvent { } function createScopedOnMessageEvent(senderId: number, eventName: string): Event { - const onMessage = Event.fromNodeEventEmitter(validatedIpcMain, eventName, (event, message) => ({ event, message })); + const onMessage = Event.fromNodeEventEmitter(ipcMain, eventName, (event, message) => ({ event, message })); const onMessageFromSender = Event.filter(onMessage, ({ event }) => event.sender.id === senderId); return Event.map(onMessageFromSender, ({ message }) => message ? VSBuffer.wrap(message) : message); @@ -31,7 +30,7 @@ export class Server extends IPCServer { private static readonly Clients = new Map(); private static getOnDidClientConnect(): Event { - const onHello = Event.fromNodeEventEmitter(validatedIpcMain, 'vscode:hello', ({ sender }) => sender); + const onHello = Event.fromNodeEventEmitter(ipcMain, 'vscode:hello', ({ sender }) => sender); return Event.map(onHello, webContents => { const id = webContents.id; diff --git a/src/vs/base/parts/ipc/electron-main/ipc.mp.ts b/src/vs/base/parts/ipc/electron-main/ipc.mp.ts index df6422ba227..3384832669b 100644 --- a/src/vs/base/parts/ipc/electron-main/ipc.mp.ts +++ b/src/vs/base/parts/ipc/electron-main/ipc.mp.ts @@ -3,8 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { BrowserWindow, IpcMainEvent, MessagePortMain } from 'electron'; -import { validatedIpcMain } from 'vs/base/parts/ipc/electron-main/ipcMain'; +import { BrowserWindow, ipcMain, IpcMainEvent, MessagePortMain } from 'electron'; import { Event } from 'vs/base/common/event'; import { IDisposable } from 'vs/base/common/lifecycle'; import { generateUuid } from 'vs/base/common/uuid'; @@ -51,7 +50,7 @@ export async function connect(window: BrowserWindow): Promise { // Wait until the window has returned the `MessagePort` // We need to filter by the `nonce` to ensure we listen // to the right response. - const onMessageChannelResult = Event.fromNodeEventEmitter<{ nonce: string; port: MessagePortMain }>(validatedIpcMain, 'vscode:createMessageChannelResult', (e: IpcMainEvent, nonce: string) => ({ nonce, port: e.ports[0] })); + const onMessageChannelResult = Event.fromNodeEventEmitter<{ nonce: string; port: MessagePortMain }>(ipcMain, 'vscode:createMessageChannelResult', (e: IpcMainEvent, nonce: string) => ({ nonce, port: e.ports[0] })); const { port } = await Event.toPromise(Event.once(Event.filter(onMessageChannelResult, e => e.nonce === nonce))); return port; diff --git a/src/vs/base/parts/ipc/electron-main/ipcMain.ts b/src/vs/base/parts/ipc/electron-main/ipcMain.ts deleted file mode 100644 index 22748f47e27..00000000000 --- a/src/vs/base/parts/ipc/electron-main/ipcMain.ts +++ /dev/null @@ -1,138 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import { ipcMain as unsafeIpcMain, IpcMainEvent, IpcMainInvokeEvent } from 'electron'; -import { onUnexpectedError } from 'vs/base/common/errors'; -import { Event } from 'vs/base/common/event'; - -type ipcMainListener = (event: IpcMainEvent, ...args: any[]) => void; - -class ValidatedIpcMain implements Event.NodeEventEmitter { - - // We need to keep a map of original listener to the wrapped variant in order - // to properly implement `removeListener`. We use a `WeakMap` because we do - // not want to prevent the `key` of the map to get garbage collected. - private readonly mapListenerToWrapper = new WeakMap(); - - /** - * Listens to `channel`, when a new message arrives `listener` would be called with - * `listener(event, args...)`. - */ - on(channel: string, listener: ipcMainListener): this { - - // Remember the wrapped listener so that later we can - // properly implement `removeListener`. - const wrappedListener = (event: IpcMainEvent, ...args: any[]) => { - if (this.validateEvent(channel, event)) { - listener(event, ...args); - } - }; - - this.mapListenerToWrapper.set(listener, wrappedListener); - - unsafeIpcMain.on(channel, wrappedListener); - - return this; - } - - /** - * Adds a one time `listener` function for the event. This `listener` is invoked - * only the next time a message is sent to `channel`, after which it is removed. - */ - once(channel: string, listener: ipcMainListener): this { - unsafeIpcMain.once(channel, (event: IpcMainEvent, ...args: any[]) => { - if (this.validateEvent(channel, event)) { - listener(event, ...args); - } - }); - - return this; - } - - /** - * Adds a handler for an `invoke`able IPC. This handler will be called whenever a - * renderer calls `ipcRenderer.invoke(channel, ...args)`. - * - * If `listener` returns a Promise, the eventual result of the promise will be - * returned as a reply to the remote caller. Otherwise, the return value of the - * listener will be used as the value of the reply. - * - * The `event` that is passed as the first argument to the handler is the same as - * that passed to a regular event listener. It includes information about which - * WebContents is the source of the invoke request. - * - * Errors thrown through `handle` in the main process are not transparent as they - * are serialized and only the `message` property from the original error is - * provided to the renderer process. Please refer to #24427 for details. - */ - handle(channel: string, listener: (event: IpcMainInvokeEvent, ...args: any[]) => Promise): this { - unsafeIpcMain.handle(channel, (event: IpcMainInvokeEvent, ...args: any[]) => { - if (this.validateEvent(channel, event)) { - return listener(event, ...args); - } - - return Promise.reject(`Invalid channel '${channel}' or sender for ipcMain.handle() usage.`); - }); - - return this; - } - - /** - * Removes any handler for `channel`, if present. - */ - removeHandler(channel: string): this { - unsafeIpcMain.removeHandler(channel); - - return this; - } - - /** - * Removes the specified `listener` from the listener array for the specified - * `channel`. - */ - removeListener(channel: string, listener: ipcMainListener): this { - const wrappedListener = this.mapListenerToWrapper.get(listener); - if (wrappedListener) { - unsafeIpcMain.removeListener(channel, wrappedListener); - this.mapListenerToWrapper.delete(listener); - } - - return this; - } - - private validateEvent(channel: string, event: IpcMainEvent | IpcMainInvokeEvent): boolean { - if (!channel || !channel.startsWith('vscode:')) { - onUnexpectedError(`Refused to handle ipcMain event for channel '${channel}' because the channel is unknown.`); - return false; // unexpected channel - } - - const sender = event.senderFrame; - if (!sender) { - return true; // happens when renderer uses `ipcRenderer.postMessage` (TODO@bpasero revisit with newer Electron version) - } - - const host = new URL(sender.url).host; - if (host !== 'vscode-app') { - onUnexpectedError(`Refused to handle ipcMain event for channel '${channel}' because of a bad origin of '${host}'.`); - return false; // unexpected sender - } - - if (sender.parent !== null) { - onUnexpectedError(`Refused to handle ipcMain event for channel '${channel}' because sender of origin '${host}' is not a main frame.`); - return false; // unexpected frame - } - - return true; - } -} - -/** - * A drop-in replacement of `ipcMain` that validates the sender of a message - * according to https://github.com/electron/electron/blob/main/docs/tutorial/security.md - * - * @deprecated direct use of Electron IPC is not encouraged. We have utilities in place - * to create services on top of IPC, see `ProxyChannel` for more information. - */ -export const validatedIpcMain = new ValidatedIpcMain(); diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index a668f8c1ab8..82260d4a427 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -3,8 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { app, BrowserWindow, contentTracing, dialog, protocol, session, Session, systemPreferences, WebFrameMain } from 'electron'; -import { validatedIpcMain } from 'vs/base/parts/ipc/electron-main/ipcMain'; +import { app, BrowserWindow, contentTracing, dialog, ipcMain, protocol, session, Session, systemPreferences, WebFrameMain } from 'electron'; import { statSync } from 'fs'; import { hostname, release } from 'os'; import { VSBuffer } from 'vs/base/common/buffer'; @@ -381,7 +380,7 @@ export class CodeApplication extends Disposable { //#region Bootstrap IPC Handlers - validatedIpcMain.handle('vscode:fetchShellEnv', event => { + ipcMain.handle('vscode:fetchShellEnv', event => { // Prefer to use the args and env from the target window // when resolving the shell env. It is possible that @@ -406,7 +405,7 @@ export class CodeApplication extends Disposable { return this.resolveShellEnvironment(args, env, false); }); - validatedIpcMain.handle('vscode:writeNlsFile', (event, path: unknown, data: unknown) => { + ipcMain.handle('vscode:writeNlsFile', (event, path: unknown, data: unknown) => { const uri = this.validateNlsPath([path]); if (!uri || typeof data !== 'string') { throw new Error('Invalid operation (vscode:writeNlsFile)'); @@ -415,7 +414,7 @@ export class CodeApplication extends Disposable { return this.fileService.writeFile(uri, VSBuffer.fromString(data)); }); - validatedIpcMain.handle('vscode:readNlsFile', async (event, ...paths: unknown[]) => { + ipcMain.handle('vscode:readNlsFile', async (event, ...paths: unknown[]) => { const uri = this.validateNlsPath(paths); if (!uri) { throw new Error('Invalid operation (vscode:readNlsFile)'); @@ -424,10 +423,10 @@ export class CodeApplication extends Disposable { return (await this.fileService.readFile(uri)).value.toString(); }); - validatedIpcMain.on('vscode:toggleDevTools', event => event.sender.toggleDevTools()); - validatedIpcMain.on('vscode:openDevTools', event => event.sender.openDevTools()); + ipcMain.on('vscode:toggleDevTools', event => event.sender.toggleDevTools()); + ipcMain.on('vscode:openDevTools', event => event.sender.openDevTools()); - validatedIpcMain.on('vscode:reloadWindow', event => event.sender.reload()); + ipcMain.on('vscode:reloadWindow', event => event.sender.reload()); //#endregion } diff --git a/src/vs/platform/diagnostics/electron-main/diagnosticsMainService.ts b/src/vs/platform/diagnostics/electron-main/diagnosticsMainService.ts index e8b236510d8..ca6c0f9cdd2 100644 --- a/src/vs/platform/diagnostics/electron-main/diagnosticsMainService.ts +++ b/src/vs/platform/diagnostics/electron-main/diagnosticsMainService.ts @@ -3,8 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { Event as IpcEvent } from 'electron'; -import { validatedIpcMain } from 'vs/base/parts/ipc/electron-main/ipcMain'; +import { Event as IpcEvent, ipcMain } from 'electron'; import { CancellationToken } from 'vs/base/common/cancellation'; import { URI } from 'vs/base/common/uri'; import { IDiagnosticInfo, IDiagnosticInfoOptions, IRemoteDiagnosticError, IRemoteDiagnosticInfo } from 'vs/platform/diagnostics/common/diagnostics'; @@ -50,7 +49,7 @@ export class DiagnosticsMainService implements IDiagnosticsMainService { window.sendWhenReady('vscode:getDiagnosticInfo', CancellationToken.None, { replyChannel, args }); - validatedIpcMain.once(replyChannel, (_: IpcEvent, data: IRemoteDiagnosticInfo) => { + ipcMain.once(replyChannel, (_: IpcEvent, data: IRemoteDiagnosticInfo) => { // No data is returned if getting the connection fails. if (!data) { resolve({ hostName: remoteAuthority, errorMessage: `Unable to resolve connection to '${remoteAuthority}'.` }); diff --git a/src/vs/platform/issue/electron-main/issueMainService.ts b/src/vs/platform/issue/electron-main/issueMainService.ts index a61b652845a..828e7ae65b3 100644 --- a/src/vs/platform/issue/electron-main/issueMainService.ts +++ b/src/vs/platform/issue/electron-main/issueMainService.ts @@ -3,8 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { BrowserWindow, BrowserWindowConstructorOptions, Display, IpcMainEvent, screen } from 'electron'; -import { validatedIpcMain } from 'vs/base/parts/ipc/electron-main/ipcMain'; +import { BrowserWindow, BrowserWindowConstructorOptions, Display, ipcMain, IpcMainEvent, screen } from 'electron'; import { arch, release, type } from 'os'; import { mnemonicButtonLabel } from 'vs/base/common/labels'; import { DisposableStore } from 'vs/base/common/lifecycle'; @@ -66,14 +65,14 @@ export class IssueMainService implements ICommonIssueService { } private registerListeners(): void { - validatedIpcMain.on('vscode:issueSystemInfoRequest', async event => { + ipcMain.on('vscode:issueSystemInfoRequest', async event => { const [info, remoteData] = await Promise.all([this.launchMainService.getMainProcessInfo(), this.diagnosticsMainService.getRemoteDiagnostics({ includeProcesses: false, includeWorkspaceMetadata: false })]); const msg = await this.diagnosticsService.getSystemInfo(info, remoteData); this.safeSend(event, 'vscode:issueSystemInfoResponse', msg); }); - validatedIpcMain.on('vscode:listProcesses', async event => { + ipcMain.on('vscode:listProcesses', async event => { const processes = []; try { @@ -103,7 +102,7 @@ export class IssueMainService implements ICommonIssueService { this.safeSend(event, 'vscode:listProcessesResponse', processes); }); - validatedIpcMain.on('vscode:issueReporterClipboard', async event => { + ipcMain.on('vscode:issueReporterClipboard', async event => { const messageOptions = { title: this.productService.nameLong, message: localize('issueReporterWriteToClipboard', "There is too much data to send to GitHub directly. The data will be copied to the clipboard, please paste it into the GitHub issue page that is opened."), @@ -123,12 +122,12 @@ export class IssueMainService implements ICommonIssueService { } }); - validatedIpcMain.on('vscode:issuePerformanceInfoRequest', async event => { + ipcMain.on('vscode:issuePerformanceInfoRequest', async event => { const performanceInfo = await this.getPerformanceInfo(); this.safeSend(event, 'vscode:issuePerformanceInfoResponse', performanceInfo); }); - validatedIpcMain.on('vscode:issueReporterConfirmClose', async () => { + ipcMain.on('vscode:issueReporterConfirmClose', async () => { const messageOptions = { title: this.productService.nameLong, message: localize('confirmCloseIssueReporter', "Your input will not be saved. Are you sure you want to close this window?"), @@ -153,7 +152,7 @@ export class IssueMainService implements ICommonIssueService { } }); - validatedIpcMain.on('vscode:workbenchCommand', (_: unknown, commandInfo: { id: any; from: any; args: any }) => { + ipcMain.on('vscode:workbenchCommand', (_: unknown, commandInfo: { id: any; from: any; args: any }) => { const { id, from, args } = commandInfo; let parentWindow: BrowserWindow | null; @@ -173,23 +172,23 @@ export class IssueMainService implements ICommonIssueService { } }); - validatedIpcMain.on('vscode:openExternal', (_: unknown, arg: string) => { + ipcMain.on('vscode:openExternal', (_: unknown, arg: string) => { this.nativeHostMainService.openExternal(undefined, arg); }); - validatedIpcMain.on('vscode:closeIssueReporter', event => { + ipcMain.on('vscode:closeIssueReporter', event => { if (this.issueReporterWindow) { this.issueReporterWindow.close(); } }); - validatedIpcMain.on('vscode:closeProcessExplorer', event => { + ipcMain.on('vscode:closeProcessExplorer', event => { if (this.processExplorerWindow) { this.processExplorerWindow.close(); } }); - validatedIpcMain.on('vscode:windowsInfoRequest', async event => { + ipcMain.on('vscode:windowsInfoRequest', async event => { const mainProcessInfo = await this.launchMainService.getMainProcessInfo(); this.safeSend(event, 'vscode:windowsInfoResponse', mainProcessInfo.windows); }); diff --git a/src/vs/platform/lifecycle/electron-main/lifecycleMainService.ts b/src/vs/platform/lifecycle/electron-main/lifecycleMainService.ts index ae26de3e981..ac3b7bfb3b2 100644 --- a/src/vs/platform/lifecycle/electron-main/lifecycleMainService.ts +++ b/src/vs/platform/lifecycle/electron-main/lifecycleMainService.ts @@ -3,8 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { app, BrowserWindow } from 'electron'; -import { validatedIpcMain } from 'vs/base/parts/ipc/electron-main/ipcMain'; +import { app, BrowserWindow, ipcMain } from 'electron'; import { Barrier, Promises, timeout } from 'vs/base/common/async'; import { Emitter, Event } from 'vs/base/common/event'; import { Disposable, DisposableStore } from 'vs/base/common/lifecycle'; @@ -512,11 +511,11 @@ export class LifecycleMainService extends Disposable implements ILifecycleMainSe const okChannel = `vscode:ok${oneTimeEventToken}`; const cancelChannel = `vscode:cancel${oneTimeEventToken}`; - validatedIpcMain.once(okChannel, () => { + ipcMain.once(okChannel, () => { resolve(false); // no veto }); - validatedIpcMain.once(cancelChannel, () => { + ipcMain.once(cancelChannel, () => { resolve(true); // veto }); @@ -529,7 +528,7 @@ export class LifecycleMainService extends Disposable implements ILifecycleMainSe const oneTimeEventToken = this.oneTimeListenerTokenGenerator++; const replyChannel = `vscode:reply${oneTimeEventToken}`; - validatedIpcMain.once(replyChannel, () => resolve()); + ipcMain.once(replyChannel, () => resolve()); window.send('vscode:onWillUnload', { replyChannel, reason }); }); diff --git a/src/vs/platform/protocol/electron-main/protocolMainService.ts b/src/vs/platform/protocol/electron-main/protocolMainService.ts index e414b377c6e..324c8abbece 100644 --- a/src/vs/platform/protocol/electron-main/protocolMainService.ts +++ b/src/vs/platform/protocol/electron-main/protocolMainService.ts @@ -3,8 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { session } from 'electron'; -import { validatedIpcMain } from 'vs/base/parts/ipc/electron-main/ipcMain'; +import { ipcMain, session } from 'electron'; import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle'; import { TernarySearchTree } from 'vs/base/common/map'; import { FileAccess, Schemas } from 'vs/base/common/network'; @@ -139,7 +138,7 @@ export class ProtocolMainService extends Disposable implements IProtocolMainServ // Install IPC handler const channel = resource.toString(); const handler = async (): Promise => obj; - validatedIpcMain.handle(channel, handler); + ipcMain.handle(channel, handler); this.logService.trace(`IPC Object URL: Registered new channel ${channel}.`); @@ -149,7 +148,7 @@ export class ProtocolMainService extends Disposable implements IProtocolMainServ dispose: () => { this.logService.trace(`IPC Object URL: Removed channel ${channel}.`); - validatedIpcMain.removeHandler(channel); + ipcMain.removeHandler(channel); } }; } diff --git a/src/vs/platform/sharedProcess/electron-main/sharedProcess.ts b/src/vs/platform/sharedProcess/electron-main/sharedProcess.ts index f7046a4d756..3d2122e121d 100644 --- a/src/vs/platform/sharedProcess/electron-main/sharedProcess.ts +++ b/src/vs/platform/sharedProcess/electron-main/sharedProcess.ts @@ -3,8 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { BrowserWindow, Event as ElectronEvent, IpcMainEvent, MessagePortMain } from 'electron'; -import { validatedIpcMain } from 'vs/base/parts/ipc/electron-main/ipcMain'; +import { BrowserWindow, Event as ElectronEvent, ipcMain, IpcMainEvent, MessagePortMain } from 'electron'; import { Barrier } from 'vs/base/common/async'; import { Emitter, Event } from 'vs/base/common/event'; import { Disposable, DisposableStore } from 'vs/base/common/lifecycle'; @@ -50,10 +49,10 @@ export class SharedProcess extends Disposable implements ISharedProcess { private registerListeners(): void { // Shared process connections from workbench windows - validatedIpcMain.on('vscode:createSharedProcessMessageChannel', (e, nonce: string) => this.onWindowConnection(e, nonce)); + ipcMain.on('vscode:createSharedProcessMessageChannel', (e, nonce: string) => this.onWindowConnection(e, nonce)); // Shared process worker relay - validatedIpcMain.on('vscode:relaySharedProcessWorkerMessageChannel', (e, configuration: ISharedProcessWorkerConfiguration) => this.onWorkerConnection(e, configuration)); + ipcMain.on('vscode:relaySharedProcessWorkerMessageChannel', (e, configuration: ISharedProcessWorkerConfiguration) => this.onWorkerConnection(e, configuration)); // Lifecycle this._register(this.lifecycleMainService.onWillShutdown(() => this.onWillShutdown())); @@ -174,7 +173,7 @@ export class SharedProcess extends Disposable implements ISharedProcess { if (!this._whenReady) { // Overall signal that the shared process window was loaded and // all services within have been created. - this._whenReady = new Promise(resolve => validatedIpcMain.once('vscode:shared-process->electron-main=init-done', () => { + this._whenReady = new Promise(resolve => ipcMain.once('vscode:shared-process->electron-main=init-done', () => { this.logService.trace('SharedProcess: Overall ready'); resolve(); @@ -199,7 +198,7 @@ export class SharedProcess extends Disposable implements ISharedProcess { this.registerWindowListeners(); // Wait for window indicating that IPC connections are accepted - await new Promise(resolve => validatedIpcMain.once('vscode:shared-process->electron-main=ipc-ready', () => { + await new Promise(resolve => ipcMain.once('vscode:shared-process->electron-main=ipc-ready', () => { this.logService.trace('SharedProcess: IPC ready'); resolve();