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
Append chunked body responses invoked as part of _build_request #40
Append chunked body responses invoked as part of _build_request #40
Conversation
Hi @foobargeez thanks for the PR. Could you take a minute and explain the reason for this change and give an example of a problem you are trying to solve? Some example code would be great. |
This will need some tests as well so perhaps you can answer all the above with a test. |
Scenario: Created the below etcd keys:
Ran the following script:
The output is as below:
Per the above output, the output is split into two chunks. The current code in etcd is exiting the event loop right after receiving the first chunk. The patch now appends all chunks and ends the event loop only on connection disconnect. Please note that I am not sure what is special about the keys I quoted above -- the issue happens with 9 keys (not 10 or 8) and have no clue why the data gets split into chunks only with the above similar 9 keys. The key length too is important as it doesn't happen with small key lengths. Overall, a weird scenario, but nevertheless, the patch handles chunked responses by appending the output. Regarding a test case, I am not exactly sure how to come up with one and importantly a generic one. If you have any ideas, let me know and I am happy to. |
@foobargeez, thanks so lets say using the keys you added above, what code are you using with Net::Etcd to reproduce the issue? Just a simple script will be fine. Will be easier for me to review and test. |
I already added the code to my above comment. Let me know if that didn't work for you. |
To clarify further, the code I used in my comment above is the same code that I copied from Net::Etcd's Action.pm and from |
@foobargeez I understand that your using the code from the Net::Etcd source and that is useful example. But since you are making the issue against the module itself I am curious how you are using Net::Etcd. Are you doing range, watch etc? Your update breaks the Watch test. So although it solves one problem it creates others. So to clarify can you show with Net::Etcd |
Sure, that's the easy part! I got to the bottom of the issue, so started the issue from there :-/
Output:
|
Checking ... sorry :( |
I reverted my changes and ran the test and it's still failing. Looks like some other changes are causing the issue. Let me know if you need a hand digging this. |
@foobargeez can you show the output of your test failure and what version of etcd your using. I just ran the test a number of times against master without failure.
|
The test fails while creating
|
@foobargeez with your change Watch blocks, without it does not. Am I missing something?
I add your change
async watch call blocks
remove your change back to master
pass
So please before we spend anymore time in this I need Perl code using the Net::Etcd module showing unexpected output. From there we can look at a solution. |
I see your code above now nevermind. Will test and let you know, thanks. |
@foobargeez so the bug is in how we handle
You will see that all the data is already returned correctly. So we just need to make sure |
Ugh brother ok I guess I need to slow down I am going to review this more. |
@foobargeez OK so we have an issue with chunked data as you noted. But we also need to handle async streams such as Watch so they don't block. |
Yep -- sorry, I overlooked that :-/ Per the documentation of AnyEvent::HTTP, it sounds like we should start looking into
I will look into it sometime next week. |
Thanks, checkout Miyagawa's module if you haven't, might be useful. https://github.com/miyagawa/AnyEvent-Twitter-Stream/blob/master/lib/AnyEvent/Twitter/Stream.pm#L165 |
I did :-) I noted that line as well ... grr ... |
I figured I would finish it while I have the context -- please review and let me know if something is unclear. |
lgtm, thanks @foobargeez |
@foobargeez I cut a new release v0.019 is on it's way to CPAN, 👍 |
This patch ensures that the AE's
http_request
chunked response is honored and appended to the response content. Also, ensures that the event loop does not end prematurely.