wp-cli / wp-cli

⚙️ WP-CLI framework

Home Page:https://wp-cli.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a reason to keep timeouts hardcoded?

thbighead opened this issue · comments

I'm using WP-CLI to maintain WordPress environments, and sometimes I get an issue about timeout (each one with a different milliseconds value to trigger it) like that:

Error: Ocorreu um erro inesperado. Pode estar algo errado com o WordPress.org ou com a configuração deste servidor. Se continuar com problemas, por favor tente pedir ajuda no fórum de suporte. "cURL error 28: Connection timed out after 3002 milliseconds"

This one I got while executing the following command: wp language plugin install pt_PT --all

After months trying to change those timeout settings, search in documentations and hacking your code, I finally found some comments of others saying those timeout values are hard-coded for each request with a different value (which explains why the timeout values were different sometimes into the error messages) without any way to override it.

My questions are:

  • Am I missing something, or I really can't change those timeout values?
  • Why you keep all those timeouts hard-coded and impossible to override?

Hi there, could you please share the links to those code references and comments about timeouts just so we are on the same page?

The error message you shared looks like it's coming from WordPress itself, not WP-CLI, so I'd like to confirm that.

Hi there, could you please share the links to those code references and comments about timeouts just so we are on the same page?

The error message you shared looks like it's coming from WordPress itself, not WP-CLI, so I'd like to confirm that.

Like I said: maybe I'm missing something, if I have a way to change those timeout options, I'm all ears. I spent more than a month trying to change them and failed. I'm really asking for help here.

All I need is a way to change those timeout limits because in some cases the devs connection isn't this fast.

You said something about hardcoded timeout values, so I wanted to know where you saw those and what exactly you have tried so far.

WordPress has a http_request_timeout filter that can be used to adjust the default timeout of 5 seconds for any HTTP request. For example in an mu-plugin or so.

For wp plugin & co, WP-CLI already increases this timeout to 1 minute:

https://github.com/wp-cli/extension-command/blob/f9bc3fd2f2dabcbe9b3bc3dc9591535dd714fd3c/src/WP_CLI/CommandWithUpgrade.php#L53-L59

We could do the same for wp language as well I suppose.

Hm... I tried http_request_timeout filter, but... It's truly virulent. It should change all request timeouts which I don't really want to, I want to change only the ones during those WP-CLI commands which sometimes raise timeout errors with different values.

About this 1 minute timeout: how I got a 3000 millisecond error?

EDIT: Also, even using the filter, I failed to overcome the timeout error when they raise up.

Hey @thbighead,

Please watch your language in GitHub issues, and avoid the use of swear words.

It seems like this particular issue is specific to your environment, not a bug with WP-CLI. GitHub issues are meant for reproducible reports, enhancements, etc. Feel free to stop by the #cli channel on WordPress.org Slack if you'd like help debugging further.