Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More meaningful message when trying to ack message that was already acknowledged #862

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion js.go
Expand Up @@ -2552,7 +2552,7 @@ func (m *Msg) ackReply(ackType []byte, sync bool, opts ...AckOpt) error {

// Skip if already acked.
if atomic.LoadUint32(&m.ackd) == 1 {
return ErrInvalidJSAck
return ErrMsgAlreadyAckd
}

m.Sub.mu.Lock()
Expand Down
1 change: 1 addition & 0 deletions nats.go
Expand Up @@ -157,6 +157,7 @@ var (
ErrPullSubscribeRequired = errors.New("nats: must use pull subscribe to bind to pull based consumer")
ErrConsumerNotActive = errors.New("nats: consumer not active")
ErrMsgNotFound = errors.New("nats: message not found")
ErrMsgAlreadyAckd = errors.New("nats: message was already acknowledged")
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions test/js_test.go
Expand Up @@ -2571,7 +2571,7 @@ func TestJetStreamSubscribe_AckPolicy(t *testing.T) {
}

err = msg.AckSync(nats.AckWait(2 * time.Second))
if err != nats.ErrInvalidJSAck {
if err != nats.ErrMsgAlreadyAckd {
t.Errorf("Unexpected error: %v", err)
}

Expand Down Expand Up @@ -3006,7 +3006,7 @@ func TestJetStreamSubscribe_AckDup(t *testing.T) {

for i := 0; i < 5; i++ {
e := <-ch
if e != nats.ErrInvalidJSAck {
if e != nats.ErrMsgAlreadyAckd {
t.Errorf("Expected error: %v", e)
}
}
Expand Down