nats-server icon indicating copy to clipboard operation
nats-server copied to clipboard

'408 Request Timeout' instead of '404 No Messages' from $JS.API.CONSUMER.MSG.NEXT.<stream>.<consumer>

Open pablopla opened this issue 3 months ago • 4 comments

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

  1. Create a stream.
  2. Publish 5 messages to the stream.
  3. Create ephemeral consumer.
  4. Request a batch of 10 messages with no_wait:
pub $JS.API.CONSUMER.MSG.NEXT.<stream>.<consumer> reply-to
{'batch': 10, 'no_wait': true}

pablopla avatar May 01 '24 07:05 pablopla

% 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

ripienaar avatar May 01 '24 08:05 ripienaar

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
		}

Jarema avatar May 01 '24 09:05 Jarema

We could adjust for 2.11 if we feel that its confusing.

derekcollison avatar May 01 '24 15:05 derekcollison

I'll take a look at this.

Jarema avatar May 01 '24 16:05 Jarema