Skip to content

Commit 28cab79

Browse files
committed
fix: always call p.Close() in s2Producer.close even when ack drain times out
1 parent 59f817f commit 28cab79

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

server/lib/events/s2storage.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package events
33
import (
44
"context"
55
"encoding/json"
6+
"errors"
67
"fmt"
78
"log/slog"
89
"sync"
@@ -29,12 +30,13 @@ func (sp *s2Producer) close(ctx context.Context) error {
2930
sp.wg.Wait()
3031
close(done)
3132
}()
33+
var drainErr error
3234
select {
3335
case <-done:
3436
case <-ctx.Done():
35-
return ctx.Err()
37+
drainErr = ctx.Err()
3638
}
37-
return sp.p.Close()
39+
return errors.Join(drainErr, sp.p.Close())
3840
}
3941

4042
// S2Storage appends all events to a single fixed stream set at construction time.

0 commit comments

Comments
 (0)