Skip to content

Commit 62f3155

Browse files
committed
More reconnectingPTY logging
Signed-off-by: Spike Curtis <spike@coder.com>
1 parent b279f1a commit 62f3155

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

agent/agent.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,7 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m
10381038
// 1. The timeout completed.
10391039
// 2. The parent context was canceled.
10401040
<-ctx.Done()
1041+
logger.Debug(ctx, "context done", slog.Error(ctx.Err()))
10411042
_ = process.Kill()
10421043
}()
10431044
// We don't need to separately monitor for the process exiting.
@@ -1049,6 +1050,8 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m
10491050
read, err := rpty.ptty.OutputReader().Read(buffer)
10501051
if err != nil {
10511052
// When the PTY is closed, this is triggered.
1053+
// Error is typically a benign EOF, so only log for debugging.
1054+
logger.Debug(ctx, "PTY output read error", slog.Error(err))
10521055
break
10531056
}
10541057
part := buffer[:read]
@@ -1060,8 +1063,14 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m
10601063
break
10611064
}
10621065
rpty.activeConnsMutex.Lock()
1063-
for _, conn := range rpty.activeConns {
1064-
_, _ = conn.Write(part)
1066+
for cid, conn := range rpty.activeConns {
1067+
_, err = conn.Write(part)
1068+
logger.Debug(ctx,
1069+
"wrote to active conn",
1070+
slog.F("other_conn_id", cid),
1071+
slog.F("data", part),
1072+
slog.Error(err),
1073+
)
10651074
}
10661075
rpty.activeConnsMutex.Unlock()
10671076
}

0 commit comments

Comments
 (0)