Skip to content

Commit ccbcba5

Browse files
authored
debug: shut down debug sessions if an extension host goes away (microsoft#187169)
Fixes microsoft#184552
1 parent 078d0fd commit ccbcba5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/vs/workbench/api/browser/mainThreadDebugService.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { DisposableStore } from 'vs/base/common/lifecycle';
6+
import { DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
77
import { URI as uri, UriComponents } from 'vs/base/common/uri';
88
import { IDebugService, IConfig, IDebugConfigurationProvider, IBreakpoint, IFunctionBreakpoint, IBreakpointData, IDebugAdapter, IDebugAdapterDescriptorFactory, IDebugSession, IDebugAdapterFactory, IDataBreakpoint, IDebugSessionOptions, IInstructionBreakpoint, DebugConfigurationProviderTriggerKind } from 'vs/workbench/contrib/debug/common/debug';
99
import {
@@ -50,6 +50,11 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
5050
this._toDispose.add(debugService.getViewModel().onDidFocusSession(session => {
5151
this._proxy.$acceptDebugSessionActiveChanged(this.getSessionDto(session));
5252
}));
53+
this._toDispose.add(toDisposable(() => {
54+
for (const [handle, da] of this._debugAdapters) {
55+
da.fireError(handle, new Error('Extension host shut down'));
56+
}
57+
}));
5358

5459
this._debugAdapters = new Map();
5560
this._debugConfigurationProviders = new Map();

src/vs/workbench/contrib/debug/browser/rawDebugSession.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,8 @@ export class RawDebugSession implements IDisposable {
573573
args.suspendDebuggee = suspendDebuggee;
574574
}
575575

576-
await this.send('disconnect', args, undefined, 2000);
576+
// if there's an error, the DA is probably already gone, so give it a much shorter timeout.
577+
await this.send('disconnect', args, undefined, error ? 200 : 2000);
577578
} catch (e) {
578579
// Catch the potential 'disconnect' error - no need to show it to the user since the adapter is shutting down
579580
} finally {

0 commit comments

Comments
 (0)