Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug: on restart, make sure to first disconnect and only then run th… #60787

Merged
merged 2 commits into from
Oct 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 30 additions & 23 deletions src/vs/workbench/parts/debug/electron-browser/debugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,32 +539,39 @@ export class DebugService implements IDebugService {

restartSession(session: IDebugSession, restartData?: any): TPromise<any> {
return this.textFileService.saveAll().then(() => {
// Do not run preLaunch and postDebug tasks for automatic restarts
const isAutoRestart = !!restartData;
const taskPromise = isAutoRestart ? TPromise.as(TaskRunResult.Success) :
this.runTask(session.root, session.configuration.postDebugTask).then(() => this.runTaskAndCheckErrors(session.root, session.configuration.preLaunchTask));

return taskPromise.then(taskRunResult => {
if (taskRunResult !== TaskRunResult.Success) {
return;
}
if (session.capabilities.supportsRestartRequest) {
return session.restart().then(() => void 0);
const runTasks: () => TPromise<TaskRunResult> = () => {
if (isAutoRestart) {
// Do not run preLaunch and postDebug tasks for automatic restarts
return TPromise.as(TaskRunResult.Success);
}

const shouldFocus = this.viewModel.focusedSession && session.getId() === this.viewModel.focusedSession.getId();
if (isExtensionHostDebugging(session.configuration) && session.root) {
return this.broadcastService.broadcast({
channel: EXTENSION_RELOAD_BROADCAST_CHANNEL,
payload: [session.root.uri.toString()]
});
}
return this.runTask(session.root, session.configuration.postDebugTask)
.then(() => this.runTaskAndCheckErrors(session.root, session.configuration.preLaunchTask));
};

if (session.capabilities.supportsRestartRequest) {
return runTasks().then(taskResult => taskResult === TaskRunResult.Success ? session.restart() : undefined).then(() => void 0);
}

// If the restart is automatic -> disconnect, otherwise -> terminate #55064
return (isAutoRestart ? session.disconnect(true) : session.terminate(true)).then(() => {
if (isExtensionHostDebugging(session.configuration) && session.root) {
return runTasks().then(taskResult => taskResult === TaskRunResult.Success ? this.broadcastService.broadcast({
channel: EXTENSION_RELOAD_BROADCAST_CHANNEL,
payload: [session.root.uri.toString()]
}) : undefined);
}

const shouldFocus = this.viewModel.focusedSession && session.getId() === this.viewModel.focusedSession.getId();
// If the restart is automatic -> disconnect, otherwise -> terminate #55064
return (isAutoRestart ? session.disconnect(true) : session.terminate(true)).then(() => {

return new TPromise<void>((c, e) => {
setTimeout(() => {
runTasks().then(taskResult => {
if (taskResult !== TaskRunResult.Success) {
return;
}

return new TPromise<void>((c, e) => {
setTimeout(() => {
// Read the configuration again if a launch.json has been changed, if not just use the inmemory configuration
let needsToSubstitute = false;
let unresolved: IConfig;
Expand Down Expand Up @@ -594,8 +601,8 @@ export class DebugService implements IDebugService {
c(null);
}, err => e(err));
});
}, 300);
});
});
}, 300);
});
});
});
Expand Down