Skip to content

Commit a781173

Browse files
committed
Avoid clobbering attach error with close errors
We want to send the error from failing to wait for the version command, not the error from closing/killing the pty or process.
1 parent 3ff1510 commit a781173

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

agent/reconnectingpty/screen.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,13 @@ func (rpty *screenReconnectingPTY) doAttach(ctx context.Context, height, width u
279279
// the same name.
280280
err = rpty.sendCommand(ctx, "version", nil)
281281
if err != nil {
282-
err := ptty.Close()
283-
if err != nil {
284-
logger.Debug(ctx, "closed ptty with error", slog.Error(err))
282+
closeErr := ptty.Close()
283+
if closeErr != nil {
284+
logger.Debug(ctx, "closed ptty with error", slog.Error(closeErr))
285285
}
286-
err = process.Kill()
287-
if err != nil {
288-
logger.Debug(ctx, "killed process with error", slog.Error(err))
286+
closeErr = process.Kill()
287+
if closeErr != nil {
288+
logger.Debug(ctx, "killed process with error", slog.Error(closeErr))
289289
}
290290
rpty.metrics.WithLabelValues("screen_wait").Add(1)
291291
return nil, nil, err

0 commit comments

Comments
 (0)