Skip to content

Commit 0aef5fb

Browse files
committed
src/goDebugFactory: log errors without killing delve process
Certain errors on dlv launch are expected / accepted. Don't kill the debug session. Fixes #1678 Change-Id: I2cd835c04d2f4f261c6a4b9ac9c965a5b9beea85 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/341209 Trust: Suzy Mueller <[email protected]> Trust: Hyang-Ah Hana Kim <[email protected]> Run-TryBot: Suzy Mueller <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]> (cherry picked from commit 6a6fdb6) Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/341229
1 parent 457fad3 commit 0aef5fb

File tree

1 file changed

+7
-30
lines changed

1 file changed

+7
-30
lines changed

src/goDebugFactory.ts

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class GoDebugAdapterTrackerFactory implements vscode.DebugAdapterTrackerF
5757
onWillStartSession: () =>
5858
logger.debug(`session ${session.id} will start with ${JSON.stringify(session.configuration)}\n`),
5959
onWillReceiveMessage: (message: any) => logger.trace(`client -> ${JSON.stringify(message)}\n`),
60-
onDidSendMessage: (message: any) => logger.trace(`client <- ${JSON.stringify(message)}\n`),
60+
onDidSendMessage: (message: any) => logger.trace(`client <- ${JSON.stringify(message)}\n`),
6161
onError: (error: Error) => logger.error(`error: ${error}\n`),
6262
onWillStopSession: () => logger.debug(`session ${session.id} will stop\n`),
6363
onExit: (code: number | undefined, signal: string | undefined) =>
@@ -427,43 +427,26 @@ function spawnDlvDapServerProcess(
427427
5_000
428428
);
429429

430-
const stopWaitingForServerToStart = (err?: string) => {
430+
const stopWaitingForServerToStart = () => {
431431
clearTimeout(timeoutToken);
432432
started = true;
433-
if (err) {
434-
logConsole(`Failed to start 'dlv': ${err}\nKilling the dlv process...`);
435-
killProcessTree(p); // We do not need to wait for p to actually be killed.
436-
reject(new Error(err));
437-
} else {
438-
resolve(p);
439-
}
433+
resolve(p);
440434
};
441435

442436
p.stdout.on('data', (chunk) => {
443437
const msg = chunk.toString();
444-
if (!started) {
445-
if (msg.startsWith('DAP server listening at:')) {
446-
stopWaitingForServerToStart();
447-
} else {
448-
stopWaitingForServerToStart(`Unexpected output from dlv dap on start: '${msg}'`);
449-
}
438+
if (!started && msg.startsWith('DAP server listening at:')) {
439+
stopWaitingForServerToStart();
450440
}
451441
log(msg);
452442
});
453443
p.stderr.on('data', (chunk) => {
454-
if (!started) {
455-
stopWaitingForServerToStart(`Unexpected error from dlv dap on start: '${chunk.toString()}'`);
456-
}
457444
logErr(chunk.toString());
458445
});
459446
p.stdio[3].on('data', (chunk) => {
460447
const msg = chunk.toString();
461-
if (!started) {
462-
if (msg.startsWith('DAP server listening at:')) {
463-
stopWaitingForServerToStart();
464-
} else {
465-
stopWaitingForServerToStart(`Expected 'DAP server listening at:' from debug adapter got '${msg}'`);
466-
}
448+
if (!started && msg.startsWith('DAP server listening at:')) {
449+
stopWaitingForServerToStart();
467450
}
468451
if (logDestStream) {
469452
// always false on windows.
@@ -489,9 +472,6 @@ function spawnDlvDapServerProcess(
489472
// respond to disconnect on time. In that case, it's possible that the session
490473
// is in the middle of teardown and DEBUG CONSOLE isn't accessible. Check
491474
// Go Debug output channel.
492-
if (!started) {
493-
stopWaitingForServerToStart(`dlv dap terminated with code: ${code} signal: ${signal}\n`);
494-
}
495475
if (typeof code === 'number') {
496476
// The process exited on its own.
497477
logConsole(`dlv dap (${p.pid}) exited with code: ${code}\n`);
@@ -502,9 +482,6 @@ function spawnDlvDapServerProcess(
502482
}
503483
});
504484
p.on('error', (err) => {
505-
if (!started) {
506-
stopWaitingForServerToStart(`Unexpected error from dlv dap on start: '${err}'`);
507-
}
508485
if (err) {
509486
logConsole(`Error: ${err}\n`);
510487
}

0 commit comments

Comments
 (0)