Skip to content

Commit d2c7a1f

Browse files
committed
Unit tests do not handle error log well
1 parent eb2497a commit d2c7a1f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

coderd/workspaceagents.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,10 +639,15 @@ func (api *API) workspaceAgentCoordinate(rw http.ResponseWriter, r *http.Request
639639
}
640640
err := updateConnectionTimes(ctx)
641641
if err != nil {
642-
api.Logger.Error(ctx, "failed to update agent disconnect time",
643-
slog.Error(err),
644-
slog.F("workspace", build.WorkspaceID),
645-
)
642+
// This is a bug with unit tests that cancel the app context and
643+
// cause this error log to be generated. We should fix the unit tests
644+
// as this is a valid log.
645+
if !xerrors.Is(err, context.Canceled) {
646+
api.Logger.Error(ctx, "failed to update agent disconnect time",
647+
slog.Error(err),
648+
slog.F("workspace", build.WorkspaceID),
649+
)
650+
}
646651
}
647652
api.publishWorkspaceUpdate(ctx, build.WorkspaceID)
648653
}()

0 commit comments

Comments
 (0)