Skip to content

Commit

Permalink
sandbox - mitigate native crash from ipcRenderer usages (#157765) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero authored and joyceerhl committed Aug 10, 2022
1 parent 8f562f3 commit dfd7770
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class SharedProcessMain extends Disposable {
// application is shutting down anyways.
//
const eventName = 'vscode:electron-main->shared-process=disposeWorker';
const onDisposeWorker = (event: unknown, configuration: ISharedProcessWorkerConfiguration) => this.onDisposeWorker(configuration);
const onDisposeWorker = (event: unknown, configuration: ISharedProcessWorkerConfiguration) => { this.onDisposeWorker(configuration); };
ipcRenderer.on(eventName, onDisposeWorker);
this._register(toDisposable(() => ipcRenderer.removeListener(eventName, onDisposeWorker)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class TerminalNativeContribution extends Disposable implements IWorkbench
) {
super();

ipcRenderer.on('vscode:openFiles', (_: unknown, request: INativeOpenFileRequest) => this._onOpenFileRequest(request));
ipcRenderer.on('vscode:openFiles', (_: unknown, request: INativeOpenFileRequest) => { this._onOpenFileRequest(request); });
this._register(nativeHostService.onDidResumeOS(() => this._onOsResume()));

this._terminalService.setNativeDelegate({
Expand Down
48 changes: 26 additions & 22 deletions src/vs/workbench/electron-sandbox/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,36 +180,40 @@ export class NativeWindow extends Disposable {
});

// Support openFiles event for existing and new files
ipcRenderer.on('vscode:openFiles', (event: unknown, request: IOpenFileRequest) => this.onOpenFiles(request));
ipcRenderer.on('vscode:openFiles', (event: unknown, request: IOpenFileRequest) => { this.onOpenFiles(request); });

// Support addFolders event if we have a workspace opened
ipcRenderer.on('vscode:addFolders', (event: unknown, request: IAddFoldersRequest) => this.onAddFoldersRequest(request));
ipcRenderer.on('vscode:addFolders', (event: unknown, request: IAddFoldersRequest) => { this.onAddFoldersRequest(request); });

// Message support
ipcRenderer.on('vscode:showInfoMessage', (event: unknown, message: string) => this.notificationService.info(message));
ipcRenderer.on('vscode:showInfoMessage', (event: unknown, message: string) => { this.notificationService.info(message); });

// Shell Environment Issue Notifications
ipcRenderer.on('vscode:showResolveShellEnvError', (event: unknown, message: string) => this.notificationService.prompt(
Severity.Error,
message,
[{
label: localize('learnMore', "Learn More"),
run: () => this.openerService.open('https://go.microsoft.com/fwlink/?linkid=2149667')
}]
));

ipcRenderer.on('vscode:showCredentialsError', (event: unknown, message: string) => this.notificationService.prompt(
Severity.Error,
localize('keychainWriteError', "Writing login information to the keychain failed with error '{0}'.", message),
[{
label: localize('troubleshooting', "Troubleshooting Guide"),
run: () => this.openerService.open('https://go.microsoft.com/fwlink/?linkid=2190713')
}]
));
ipcRenderer.on('vscode:showResolveShellEnvError', (event: unknown, message: string) => {
this.notificationService.prompt(
Severity.Error,
message,
[{
label: localize('learnMore', "Learn More"),
run: () => this.openerService.open('https://go.microsoft.com/fwlink/?linkid=2149667')
}]
);
});

ipcRenderer.on('vscode:showCredentialsError', (event: unknown, message: string) => {
this.notificationService.prompt(
Severity.Error,
localize('keychainWriteError', "Writing login information to the keychain failed with error '{0}'.", message),
[{
label: localize('troubleshooting', "Troubleshooting Guide"),
run: () => this.openerService.open('https://go.microsoft.com/fwlink/?linkid=2190713')
}]
);
});

// Fullscreen Events
ipcRenderer.on('vscode:enterFullScreen', async () => setFullscreen(true));
ipcRenderer.on('vscode:leaveFullScreen', async () => setFullscreen(false));
ipcRenderer.on('vscode:enterFullScreen', async () => { setFullscreen(true); });
ipcRenderer.on('vscode:leaveFullScreen', async () => { setFullscreen(false); });

// Proxy Login Dialog
ipcRenderer.on('vscode:openProxyAuthenticationDialog', async (event: unknown, payload: { authInfo: AuthInfo; username?: string; password?: string; replyChannel: string }) => {
Expand Down

0 comments on commit dfd7770

Please sign in to comment.