Skip to content

Commit db72703

Browse files
suzmuehyangah
authored andcommitted
[release] src/goDebugFactory.ts: send the first error when starting dlv-dap
For every message that the thin adapter needs to forward to dlv-dap, the thin adapter needs to make sure it can connect to the server. If there was an error connecting to the server it will send an error message and a terminated event so the client knows the debug session is not active. If multiple messages are sent to the server, the user gets shown multiple error messages. This change records whether we have already sent a terminated event because of an error, and will not send duplicate error messages. Fixes #1426 Change-Id: I8b81959b529f3802c9aa2cbebdbe8008af5902b3 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/310517 Trust: Suzy Mueller <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]> (cherry picked from commit bd55732) Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/311452 Trust: Hyang-Ah Hana Kim <[email protected]> Run-TryBot: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]> Reviewed-by: Suzy Mueller <[email protected]>
1 parent a7a34ac commit db72703

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/goDebugFactory.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ export class DelveDAPOutputAdapter extends ProxyDebugAdapter {
168168
private dlvDapServer: ChildProcess;
169169
private port: number;
170170
private socket: net.Socket;
171+
private terminatedOnError = false;
171172

172173
protected async sendMessageToServer(message: vscode.DebugProtocolMessage): Promise<void> {
173174
if (!this.connected) {
@@ -177,14 +178,19 @@ export class DelveDAPOutputAdapter extends ProxyDebugAdapter {
177178
await this.connected;
178179
super.sendMessageToServer(message);
179180
} catch (err) {
181+
if (this.terminatedOnError) {
182+
return;
183+
}
184+
this.terminatedOnError = true;
180185
// If there was an error connecting, show an error message
181186
// and send a terminated event, since we cannot start.
182187
if (err) {
183-
const errMsg = `connect to server error: ${err}`;
184-
this.sendMessageToClient(new OutputEvent(errMsg));
188+
const errMsg = `Debug Error: ${err}`;
189+
this.outputEvent(errMsg, 'stderr');
185190
vscode.window.showErrorMessage(errMsg);
186191
}
187192
this.sendMessageToClient(new TerminatedEvent());
193+
return;
188194
}
189195
}
190196

0 commit comments

Comments
 (0)