debug: shut down debug sessions if an extension host goes away (#187169)

Fixes #184552
This commit is contained in:
Connor Peet 2023-07-06 11:04:59 -07:00 committed by GitHub
parent 078d0fd6e3
commit ccbcba53e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { DisposableStore } from 'vs/base/common/lifecycle';
import { DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
import { URI as uri, UriComponents } from 'vs/base/common/uri';
import { IDebugService, IConfig, IDebugConfigurationProvider, IBreakpoint, IFunctionBreakpoint, IBreakpointData, IDebugAdapter, IDebugAdapterDescriptorFactory, IDebugSession, IDebugAdapterFactory, IDataBreakpoint, IDebugSessionOptions, IInstructionBreakpoint, DebugConfigurationProviderTriggerKind } from 'vs/workbench/contrib/debug/common/debug';
import {
@ -50,6 +50,11 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
this._toDispose.add(debugService.getViewModel().onDidFocusSession(session => {
this._proxy.$acceptDebugSessionActiveChanged(this.getSessionDto(session));
}));
this._toDispose.add(toDisposable(() => {
for (const [handle, da] of this._debugAdapters) {
da.fireError(handle, new Error('Extension host shut down'));
}
}));
this._debugAdapters = new Map();
this._debugConfigurationProviders = new Map();

View file

@ -573,7 +573,8 @@ export class RawDebugSession implements IDisposable {
args.suspendDebuggee = suspendDebuggee;
}
await this.send('disconnect', args, undefined, 2000);
// if there's an error, the DA is probably already gone, so give it a much shorter timeout.
await this.send('disconnect', args, undefined, error ? 200 : 2000);
} catch (e) {
// Catch the potential 'disconnect' error - no need to show it to the user since the adapter is shutting down
} finally {