-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
SSE with rest-client-reactive may lose message content when it incorrectly breaks the message delimiter (\n\n) #37625
Comments
/cc @cescoffier (rest-client), @geoand (rest-client) |
Is there any chance you can add a sample application that reproduces the problem? It will be very helpful in order debugging and creating a test. Thanks |
@geoand Here is an example with two test cases: one that is expected and another that is unexpected. |
Thanks |
I have not had time to look into yet. Hopefully early next week |
Update: |
SSEParser:
Yes.... exactly that. |
@FroMage do you have any bandwidth to fix the parser? |
This looks like we're screwed if HTTP chunks between
So, actually there are lots of ways where chunking would work, such as if it happens within a 2-byte UTF8, because we will detect that something is missing. But if chunking happens in the middle of a field name, or in the middle of a value, it looks like the SSEParser will just discard the event:
This will result in:
So, we can't HTTP chunk in the middle of a line, though in this case our parser could be fixed to throw a Now, the case I don't see how we can support is if we chunk in between
Which should append both values and fire an event with value
Which means (from the SSE spec), two separate events, of values Not sure at all how we can detect that, frankly. But who generates this SSE event? Because we never generate BTW, |
I'm not talking about Please try using my sample reproducer to check the issue. |
OK, right. So in this case what happens is a variation of the first problematic case that we should fix, where we drop events:
What happens is:
Should be the same fix as the first case: if we have stuff to parse, but no firing of event, we should treat it as if we don't have enough data and not drop the input. |
Interesting that the test for this ended up in ./extensions/resteasy-reactive/quarkus-resteasy-reactive-jsonb/deployment/src/test/java/io/quarkus/resteasy/reactive/jsonb/deployment/test/sse/SseParserTest.java of all places 🤷 |
But none of the test cases in I think there should be a new test for this issue, like the following example.
|
I know.
Good news is that this is not true, we already handle chunks in all these cases by requiring bytes until an end-of-line |
Fix should be at #37866 |
Fixes quarkusio#37625 (cherry picked from commit 5070e60)
Describe the bug
The problem arises when the REST client splits the returned SEE message from the remote server into chunks. If it incorrectly breaks the message delimiter (\n\n) into two chunks, it can result in the loss of the message.
Here is an example message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It will finally be split into two chunks as follows:
chunk 1: xxxx....xxx\n
chunk 2: \n
And here is the rest client example:
And here is the breakpoint from the Http1xClientConnection.java
Chunk 1:
Chunk 2:
Expected behavior
No response
Actual behavior
No response
How to Reproduce?
No response
Output of
uname -a
orver
No response
Output of
java -version
No response
Quarkus version or git rev
3.6.1
Build tool (ie. output of
mvnw --version
orgradlew --version
)gradle 8.3
Additional information
No response
The text was updated successfully, but these errors were encountered: