Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

When delve fails, stop the debug sessions #774

Merged
merged 2 commits into from
Feb 6, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class Delve {
connection: Promise<RPCConnection>;
onstdout: (str: string) => void;
onstderr: (str: string) => void;
onclose: () => void;

constructor(mode: string, remotePath: string, port: number, host: string, program: string, args: string[], showLog: boolean, cwd: string, env: { [key: string]: string }, buildFlags: string, init: string) {
this.program = program;
Expand Down Expand Up @@ -268,9 +269,11 @@ class Delve {
connectClient(port, host);
}
});
let that = this;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why, but "this" in line 275 does not point to Delve object, it points to the ChildProcess which is why I had to resort to that = this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use a fat arrow function (code => { ... }) instead of function, then this will be correct

Copy link
Contributor Author

@ramya-rao-a ramya-rao-a Feb 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ya! doh! I thought I was doing just that... need to get coffee

this.debugProcess.on('close', function(code) {
// TODO: Report `dlv` crash to user.
logError('Process exiting with code: ' + code);
if (code !== 0 && that.onclose) { that.onclose(); }
});
this.debugProcess.on('error', function(err) {
reject(err);
Expand Down Expand Up @@ -388,6 +391,10 @@ class GoDebugSession extends DebugSession {
this.delve.onstderr = (str: string) => {
this.sendEvent(new OutputEvent(str, 'stderr'));
};
this.delve.onclose = () => {
this.sendErrorResponse(response, 3000, 'Failed to continue: Check the debug console for details.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 'failed to continue'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cos it matches with the other message for when the delve.connection fails?

verbose('Delve is closed');
};

this.delve.connection.then(() => {
this.sendEvent(new InitializedEvent());
Expand Down