Skip to content

Commit

Permalink
fix #3436: disconnect debug sessions if they cannot be gracefully ter…
Browse files Browse the repository at this point in the history
…minated

Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
  • Loading branch information
akosyakov committed Nov 8, 2018
1 parent fb43552 commit 26dea59
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/debug/src/browser/debug-session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,28 @@ export class DebugSession implements CompositeTreeElement {
if (!this.terminated && this.capabilities.supportsTerminateRequest && this.configuration.request === 'launch') {
this.terminated = true;
await this.connection.sendRequest('terminate', { restart });
if (!await this.exited(1000)) {
await this.disconnect(restart);
}
} else {
await this.sendRequest('disconnect', { restart });
await this.disconnect(restart);
}
}
protected exited(timeout: number): Promise<boolean> {
return new Promise<boolean>(resolve => {
const listener = this.on('exited', () => {
listener.dispose();
resolve(true);
});
setTimeout(() => {
listener.dispose();
resolve(false);
}, timeout);
});
}
protected async disconnect(restart?: boolean): Promise<void> {
await this.sendRequest('disconnect', { restart });
}

async restart(): Promise<boolean> {
if (this.capabilities.supportsRestartRequest) {
Expand Down

0 comments on commit 26dea59

Please sign in to comment.