Leave the local extension host running when connection is lost to the remote extension host

This commit is contained in:
Alexandru Dima
2021-01-15 22:12:23 +01:00
parent 3a9daf3e34
commit b813d5dd30
3 changed files with 13 additions and 1 deletions
@@ -229,6 +229,9 @@ export function activate(context: vscode.ExtensionContext) {
}
vscode.workspace.registerRemoteAuthorityResolver('test', {
async resolve(_authority: string): Promise<vscode.ResolvedAuthority> {
setTimeout(async () => {
await vscode.window.showErrorMessage('Just a custom message.', { modal: true, useCustom: true }, 'OK', 'Great');
}, 2000);
throw vscode.RemoteAuthorityResolverError.NotAvailable('Intentional Error', true);
}
});
@@ -464,7 +464,9 @@ export abstract class AbstractExtensionService extends Disposable implements IEx
protected _onExtensionHostCrashed(extensionHost: ExtensionHostManager, code: number, signal: string | null): void {
console.error('Extension host terminated unexpectedly. Code: ', code, ' Signal: ', signal);
this._stopExtensionHosts();
if (extensionHost.kind === ExtensionHostKind.LocalProcess) {
this._stopExtensionHosts();
}
}
//#region IExtensionService
@@ -57,6 +57,7 @@ export class RemoteExtensionHost extends Disposable implements IExtensionHost {
public readonly onExit: Event<[number, string | null]> = this._onExit.event;
private _protocol: PersistentProtocol | null;
private _hasLostConnection: boolean;
private _terminating: boolean;
private readonly _isExtensionDevHost: boolean;
@@ -77,6 +78,7 @@ export class RemoteExtensionHost extends Disposable implements IExtensionHost {
super();
this.remoteAuthority = this._initDataProvider.remoteAuthority;
this._protocol = null;
this._hasLostConnection = false;
this._terminating = false;
this._register(this._lifecycleService.onShutdown(reason => this.dispose()));
@@ -188,6 +190,11 @@ export class RemoteExtensionHost extends Disposable implements IExtensionHost {
}
private _onExtHostConnectionLost(): void {
if (this._hasLostConnection) {
// avoid re-entering this method
return;
}
this._hasLostConnection = true;
if (this._isExtensionDevHost && this._environmentService.debugExtensionHost.debugId) {
this._extensionHostDebugService.close(this._environmentService.debugExtensionHost.debugId);