Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (t *Topic[T]) ReceiveSince(ctx context.Context, id uint64) (uint64, []T, er
case <-c:
return t.ReceiveSince(ctx, lastIDWhenStarted)
case <-ctx.Done():
return 0, nil, ctx.Err()
return 0, nil, context.Cause(ctx)
}
}

Expand Down
15 changes: 15 additions & 0 deletions topic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,21 @@ func TestTopicWithNilPointers(t *testing.T) {
}
}

func TestReceiveSinceUsesContextCause(t *testing.T) {
testErr := errors.New("test error")
ctx, cancelCause := context.WithCancelCause(t.Context())
cancelCause(testErr)

_, _, err := topic.New[*string]().ReceiveSince(ctx, 100)
if err == nil {
t.Errorf("expected error")
}

if !errors.Is(err, testErr) {
t.Errorf("expected testErr, got %v", err)
}
}

func cmpSlice(one, two []string) bool {
if len(one) != len(two) {
return false
Expand Down
Loading