diff --git a/coderd/batchstats/batcher.go b/coderd/batchstats/batcher.go index c97745f02a..d0b3e4fb6c 100644 --- a/coderd/batchstats/batcher.go +++ b/coderd/batchstats/batcher.go @@ -243,6 +243,10 @@ func (b *Batcher) flush(ctx context.Context, forced bool, reason string) { err = b.store.InsertWorkspaceAgentStats(ctx, *b.buf) elapsed := time.Since(start) if err != nil { + if xerrors.Is(err, context.Canceled) { + b.log.Debug(ctx, "context canceled, skipping insert of workspace agent stats", slog.F("elapsed", elapsed)) + return + } b.log.Error(ctx, "error inserting workspace agent stats", slog.Error(err), slog.F("elapsed", elapsed)) return }