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

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

Open
pablopla opened this issue May 1, 2024 · 4 comments
Labels
defect Suspected defect such as a bug or regression

Comments

@pablopla
Copy link

pablopla commented May 1, 2024

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 pablopla added the defect Suspected defect such as a bug or regression label May 1, 2024
@pablopla pablopla changed the title '408 Request Timeout' instead of '404 No Messages' from $JS.API.CONSUMER.MSG.NEXT.<streamer>.<consumer> '408 Request Timeout' instead of '404 No Messages' from $JS.API.CONSUMER.MSG.NEXT.<stream>.<consumer> May 1, 2024
@ripienaar
Copy link
Contributor

% 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

@Jarema
Copy link
Member

Jarema commented May 1, 2024

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
		}

@derekcollison
Copy link
Member

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

@Jarema
Copy link
Member

Jarema commented May 1, 2024

I'll take a look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Suspected defect such as a bug or regression
Projects
None yet
Development

No branches or pull requests

4 participants