service/dap: fix race in no debug test (#2766)

Check for a possible output event when disconnecting from a
process that has already exited.

Fixes #2763
This commit is contained in:
Suzy Mueller 2022-01-04 04:03:20 -07:00 committed by GitHub
parent fcc9561cbe
commit 5842c1fe9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1048,9 +1048,9 @@ func (s *Session) onLaunchRequest(request *dap.LaunchRequest) {
if err := cmd.Wait(); err != nil {
s.config.log.Debugf("program exited with error: %v", err)
}
close(s.noDebugProcess.exited)
s.logToConsole(proc.ErrProcessExited{Pid: cmd.ProcessState.Pid(), Status: cmd.ProcessState.ExitCode()}.Error())
s.send(&dap.TerminatedEvent{Event: *newEvent("terminated")})
close(s.noDebugProcess.exited)
}()
return
}