nats-server
nats-server copied to clipboard
'408 Request Timeout' instead of '404 No Messages' from $JS.API.CONSUMER.MSG.NEXT.<stream>.<consumer>
Observed behavior
Ephemeral consumer with 5 messages returns '408 Request Timeout' When sending
pub $JS.API.CONSUMER.MSG.NEXT.<stream>.<consumer> reply-to
{'batch': 10, 'no_wait': true}
Expected behavior
Response with status '404 No Messages' as documented.
Server and client version
nats-server: v2.10.14
Host environment
No response
Steps to reproduce
- Create a stream.
- Publish 5 messages to the stream.
- Create ephemeral consumer.
- Request a batch of 10 messages with no_wait:
pub $JS.API.CONSUMER.MSG.NEXT.<stream>.<consumer> reply-to
{'batch': 10, 'no_wait': true}
% nats req js.in.x "{{Count}}" --count 10
% nats sub -i --ack
% nats pub '$JS.API.CONSUMER.MSG.NEXT.X.PULL' --reply _INBOX.xTsW65ErOuzpA0blSfoKER.1EYmNa25 '{"batch": 20, "no_wait": true}'
I get the 10 available messages and then...
[#11] Received on "_INBOX.xTsW65ErOuzpA0blSfoKER.1EYmNa25"
Nats-Pending-Messages: 10
Nats-Pending-Bytes: 0
Status: 408
Description: Request Timeout
nil body
quick check shows that we hit this condition instead of No Messages
:
// Check expiration.
if (eos && wr.noWait && wr.d > 0) || (!wr.expires.IsZero() && now.After(wr.expires)) {
hdr := fmt.Appendf(nil, "NATS/1.0 408 Request Timeout\r\n%s: %d\r\n%s: %d\r\n\r\n", JSPullRequestPendingMsgs, wr.n, JSPullRequestPendingBytes, wr.b)
o.outq.send(newJSPubMsg(wr.reply, _EMPTY_, _EMPTY_, hdr, nil, nil, 0))
wr = remove(pre, wr)
continue
}
We could adjust for 2.11 if we feel that its confusing.
I'll take a look at this.