This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 646
When delve fails, stop the debug sessions #774
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -268,9 +269,11 @@ class Delve { | |
connectClient(port, host); | ||
} | ||
}); | ||
let that = this; | ||
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); | ||
|
@@ -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.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why 'failed to continue'? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 offunction
, thenthis
will be correctThere was a problem hiding this comment.
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