Libcurl defaults to HTTP 2 but doesn't 100% work with a proxy on the other end

I spent the day chasing mysterious and unpredictable timeouts when creating diffs with ‘arc diff’, ala https://pastebin.com/gycWsTq9. The issue was quite persistent (immediately and repeatedly retrying didn’t help), but only for some requests.

Our setup is in Google Cloud, behind their load balancer which terminates HTTPS then talks HTTP to the backend which runs Phabricator.

It turned out libcurl (within arc) was defaulting to HTTP 2 and this wasn’t working properly with the LB. This patch to libphutil fixed the issue conclusively for me: https://pastebin.com/3b7XA5Ti

I’m not the only one to have run into this, see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=233177. The root cause seems to be curl just plain not supporting talking HTTP 2 to proxies https://curl.haxx.se/docs/todo.html#Support_HTTP_2_for_HTTP_S_proxi while defaulting to HTTP 2.

I just wanted to raise this and see if you might consider baking the above curl_setopt() call into libphutil until curl supports this properly. Thanks for everything. :slight_smile:

At least at first glance, that analysis seems compelling and I expect to make a similar change as a result, although I’m going to go hunt down the constants first and make sure they exist in reasonably old versions of cURL.

I filed this upstream as https://secure.phabricator.com/T13391, did a little more research, and couldn’t anticipate any problems with the patch as presented. I adopted a functionally identical patch in https://secure.phabricator.com/D20744, which is now in “master”. Thanks for the report!