diff --git a/agent/runner/runstrategy_verbose.go b/agent/runner/runstrategy_verbose.go index f684f7242e..49cfaecec8 100644 --- a/agent/runner/runstrategy_verbose.go +++ b/agent/runner/runstrategy_verbose.go @@ -18,11 +18,11 @@ func (s *Runner) RunVerboseStrategy(ctx context.Context, cfg agentConfig.Config) s.ui.Infof("%s Starting Agent with name %s...", consoleUI.Emoji_Truck, cfg.Name) session, err := StartSession(ctx, cfg, &verboseObserver{ui: s.ui}, s.logger) - - if err != nil && errors.Is(err, ErrOtlpServerStart) { - s.ui.Errorf("%s Tracetest Agent binds to the OpenTelemetry ports 4317 and 4318 which are used to receive trace information from your system. The agent tried to bind to these ports, but failed.", consoleUI.Emoji_RedCircle) - - s.ui.Finish() + if err != nil { + if errors.Is(err, ErrOtlpServerStart) { + s.ui.Errorf("%s Tracetest Agent binds to the OpenTelemetry ports 4317 and 4318 which are used to receive trace information from your system. The agent tried to bind to these ports, but failed.", consoleUI.Emoji_RedCircle) + s.ui.Finish() + } return err } diff --git a/agent/runner/session.go b/agent/runner/session.go index a1e4a03af7..8650301652 100644 --- a/agent/runner/session.go +++ b/agent/runner/session.go @@ -28,7 +28,9 @@ type Session struct { } func (s *Session) Close() { - s.client.Close() + if s != nil && s.client != nil { + s.client.Close() + } } func (s *Session) WaitUntilDisconnected() {