Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Fix silent fails due to chunked transfer encoding problems. #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fago
Copy link

@fago fago commented Jan 10, 2019

After some debugging I figured that transfer-encoding chunked connections broke replication.

This happened with a web-server being traefik -> varnish -> nginx, but given #4 is already open it's probably not specific to the web-server's used. It works locally with a plain Apache without this fix though.

Anyway, #4 did not resolve the issue for me, but this PR does. I don't know why it should be necessary to chop off \r\n - it seems it's not.

@fago
Copy link
Author

fago commented Jan 10, 2019

Note that without the bugfix the json_decode failed silently and replicatoin did not replicate any content without error. Thus, error handling should be improved here also, but that's another issue.

@jeqq
Copy link
Member

jeqq commented Jan 11, 2019

@fago Maybe this depends by the server and it's configuration, I wonder if for your case you get that \r\n already chopped and it's still necessary for other types of servers/configurations.

Could you check if you have the \r\n and you don't get the body content already without that? If json_decode fails without this fix maybe the substr cuts from the end of the body where there is not any \r\n and makes the json invalid?

@fago
Copy link
Author

fago commented Jul 23, 2020

Yes, the \r\n was already chopped of previously.

After a while, we ran into this again. json_decoding failed again, now the \r\n was not chopped in chunks. The only symptom are errors like the following:

[warning] array_merge_recursive(): Argument #2 is not an array Replication.php:473
[warning] count(): Parameter must be an array or an object that implements Countable Replication.php:453
Requesting changed revisions (since 1589376569512515); revisions determined changed: 0
[warning] array_merge_recursive(): Argument #1 is not an array Replication.php:473

I worked over the problematic code passage a bit to make it work by simply trimming any trailing whitespaces if any for each chunk. Will update the PR in a moment.

@fago
Copy link
Author

fago commented Jul 23, 2020

I opened a new PR to keep the history of this one. -> #20

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants