nats-io / nats.go

Golang client for NATS, the cloud native messaging system.
https://nats.io
Apache License 2.0
5.53k stars 696 forks source link

jetstream.PublishMsgAsync panic #1661

Open AetheWu opened 4 months ago

AetheWu commented 4 months ago

Observed behavior

Publish messages to a stream which is not existed, then the client panic

panic: runtime error: slice bounds out of range [14:0]

goroutine 2369 [running]:
github.com/nats-io/nats.go/jetstream.(*jetStream).PublishMsgAsync(0xc00007e690, 0xc00033f810, {0xc00073e7c8, 0x1, 0x1?})
    /go/pkg/mod/github.com/nats-io/nats.go@v1.34.1/jetstream/publish.go:306 +0xa49
github.com/nats-io/nats.go/jetstream.(*jetStream).handleAsyncReply.func2()
    /go/pkg/mod/github.com/nats-io/nats.go@v1.34.1/jetstream/publish.go:398 +0xd8
created by time.goFunc
    /usr/local/go/src/time/sleep.go:177 +0x2d

Expected behavior

no panic

Server and client version

nats-server: v2.10.16 nats-client: nats.go-v1.34.1

Host environment

linux amd64; nats deploy with helm

Steps to reproduce

No response

piotrpio commented 1 month ago

Hello @AetheWu, do you have a reproduction example? I tried to reproduce this and so far I am getting a valid error (nats: no response from stream) and no panic, so it would be awesome if you could provide some more details.