shared process - show notification toast on crash (fix #212103) (#212799)

This commit is contained in:
Benjamin Pasero 2024-05-15 13:10:05 +02:00 committed by GitHub
parent 8daa0c10bf
commit 6317965640
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 0 deletions

View file

@ -989,6 +989,8 @@ export class CodeApplication extends Disposable {
private setupSharedProcess(machineId: string, sqmId: string): { sharedProcessReady: Promise<MessagePortClient>; sharedProcessClient: Promise<MessagePortClient> } {
const sharedProcess = this._register(this.mainInstantiationService.createInstance(SharedProcess, machineId, sqmId));
this._register(sharedProcess.onDidCrash(() => this.windowsMainService?.sendToFocused('vscode:reportSharedProcessCrash')));
const sharedProcessClient = (async () => {
this.logService.trace('Main->SharedProcess#connect');

View file

@ -19,6 +19,7 @@ import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtil
import { parseSharedProcessDebugPort } from 'vs/platform/environment/node/environmentService';
import { assertIsDefined } from 'vs/base/common/types';
import { SharedProcessChannelConnection, SharedProcessRawConnection, SharedProcessLifecycle } from 'vs/platform/sharedProcess/common/sharedProcess';
import { Emitter } from 'vs/base/common/event';
export class SharedProcess extends Disposable {
@ -27,6 +28,9 @@ export class SharedProcess extends Disposable {
private utilityProcess: UtilityProcess | undefined = undefined;
private utilityProcessLogListener: IDisposable | undefined = undefined;
private readonly _onDidCrash = this._register(new Emitter<void>());
readonly onDidCrash = this._onDidCrash.event;
constructor(
private readonly machineId: string,
private readonly sqmId: string,
@ -168,6 +172,8 @@ export class SharedProcess extends Disposable {
payload: this.createSharedProcessConfiguration(),
execArgv
});
this._register(this.utilityProcess.onCrash(() => this._onDidCrash.fire()));
}
private createSharedProcessConfiguration(): ISharedProcessConfiguration {

View file

@ -196,6 +196,18 @@ export class NativeWindow extends BaseWindow {
}
});
// Shared Process crash reported from main
ipcRenderer.on('vscode:reportSharedProcessCrash', (event: unknown, error: string) => {
this.notificationService.prompt(
Severity.Error,
localize('sharedProcessCrash', "A shared background process terminated unexpectedly. Please restart the application to recover."),
[{
label: localize('restart', "Restart"),
run: () => this.nativeHostService.relaunch()
}]
);
});
// Support openFiles event for existing and new files
ipcRenderer.on('vscode:openFiles', (event: unknown, request: IOpenFileRequest) => { this.onOpenFiles(request); });