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

Fixes related to JetStream errors being prematurely processed by the core request layer #288

Merged
merged 6 commits into from
May 4, 2022

Conversation

aricart
Copy link
Member

@aricart aricart commented May 3, 2022

[FIX] the base client request introspected a message and if an status code was set, it turned that into an error. The logic for this was not quite correct one requirement is for the message payload of this type of error be empty and NATS core currently can only expect error of 503 (no responders). Any interpretation of the status code unless a 503, should be delegated - in this case to JetStream which can then make better interpretation of the code (which could simply be a marker for no messages, or a request timeout on requests that have an expiration.

[CHANGE] js.pull(stream,dur) now also adds an optional expires - the expires also overrides the request timeout.

FIX #273

… code was set, it turned that into an error. The logic for this was not quite correct one requirement is for the message payload of this type of error be empty and NATS core currently can only expect error of 503 (no responders). Any interpretation of the status code unless a 503, should be delegated - in this case to JetStream which can then make better interpretation of the code (which could simply be a marker for no messages, or a request timeout on requests that have an expiration.

[CHANGE] js.pull(stream,dur) now also adds an optional expires - the expires also overrides the request timeout.

FIX #273
@aricart aricart requested a review from kozlovic May 3, 2022 19:43
Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to change your test if you are going to run against the server from the main branch...

expectError(
3000,
ErrorCode.JetStream408RequestTimeout,
"408 request canceled",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So as of server rev (nats-io/nats-server@cadf921), when you reach the maximum number of pull requests, the new request will get a 409 (Exceeded MaxWaiting), and not an old one getting a 408 (Request Canceled). This was incorrect behavior. The server release notes for the upcoming 2.8.2 will state:

### Changed
- JetStream:
    - When reaching the max number of pull requests, the server would
      evict existing pending requests (with a `408 Request Canceled`) 
      instead of sending a `409 Exceeded MaxWaiting` to the new request (#3099)

…te enum with the proper name to code symmetry.
@aricart aricart temporarily deployed to CI May 4, 2022 19:31 Inactive
// the description can be exceeded max waiting or max ack pending
return new NatsError(
description,
ErrorCode.JetStream409MaxWaitingExceeded,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why name you "409" status JetStream409MaxWaitingExceeded or JetStream409MaxAckPendingExceeded? Should it not be simply JetStream409 or JetStream409Status? The description is then used to get a better sense of what the reason was...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API breakage --- those are exported, and we added new things. But perhaps we can deprecate the old. Let's do that.

tests/jetstream_test.ts Outdated Show resolved Hide resolved
@aricart aricart temporarily deployed to CI May 4, 2022 19:58 Inactive
@aricart aricart temporarily deployed to CI May 4, 2022 20:10 Inactive
@aricart aricart requested a review from kozlovic May 4, 2022 20:11
Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@aricart aricart temporarily deployed to CI May 4, 2022 20:12 Inactive
@aricart aricart merged commit 9f67075 into main May 4, 2022
@aricart aricart deleted the fix-273 branch May 4, 2022 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NatsError code is concat of code + message?
2 participants