Skip to content

Commit a143fc3

Browse files
committed
1 parent 81cf723 commit a143fc3

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/vs/code/electron-main/sharedProcess.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
import { assign } from 'vs/base/common/objects';
77
import { memoize } from 'vs/base/common/decorators';
88
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
9-
import { BrowserWindow, ipcMain } from 'electron';
9+
import { BrowserWindow, ipcMain, WebContents, Event as ElectronEvent } from 'electron';
1010
import { ISharedProcess } from 'vs/platform/ipc/electron-main/sharedProcessMainService';
1111
import { Barrier } from 'vs/base/common/async';
1212
import { ILogService } from 'vs/platform/log/common/log';
1313
import { ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
1414
import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainService';
1515
import { toDisposable, DisposableStore } from 'vs/base/common/lifecycle';
16+
import { Event } from 'vs/base/common/event';
1617

1718
export class SharedProcess implements ISharedProcess {
1819

@@ -53,7 +54,7 @@ export class SharedProcess implements ISharedProcess {
5354
this.window.loadURL(url);
5455

5556
// Prevent the window from dying
56-
const onClose = (e: Event) => {
57+
const onClose = (e: ElectronEvent) => {
5758
this.logService.trace('SharedProcess#close prevented');
5859

5960
// We never allow to close the shared process unless we get explicitly disposed()
@@ -97,7 +98,8 @@ export class SharedProcess implements ISharedProcess {
9798
});
9899

99100
return new Promise<void>(c => {
100-
ipcMain.once('handshake:hello', ({ sender }: { sender: any }) => {
101+
const onHello = Event.once(Event.fromNodeEventEmitter(ipcMain, 'handshake:hello', ({ sender }: { sender: WebContents }) => sender));
102+
disposables.add(onHello(sender => {
101103
sender.send('handshake:hey there', {
102104
sharedIPCHandle: this.environmentService.sharedIPCHandle,
103105
args: this.environmentService.args,
@@ -106,7 +108,7 @@ export class SharedProcess implements ISharedProcess {
106108

107109
disposables.add(toDisposable(() => sender.send('handshake:goodbye')));
108110
ipcMain.once('handshake:im ready', () => c(undefined));
109-
});
111+
}));
110112
});
111113
}
112114

0 commit comments

Comments
 (0)