diff --git a/internal/proxy/accesslog/writer.go b/internal/proxy/accesslog/writer.go index b0784bdc2f..5aad0acd6d 100644 --- a/internal/proxy/accesslog/writer.go +++ b/internal/proxy/accesslog/writer.go @@ -113,12 +113,15 @@ func (l *CacheWriter) Start() { } func (l *CacheWriter) Close() { - l.mu.Lock() - defer l.mu.Unlock() l.closeOnce.Do(func() { - l.closed = true + // close auto flush close(l.closeCh) l.closeWg.Wait() + + l.mu.Lock() + defer l.mu.Unlock() + l.closed = true + // flush remaining bytes l.writer.Flush()