Make WordPress Core

Opened 2 years ago

Closed 22 months ago

Last modified 22 months ago

#57315 closed enhancement (fixed)

Increase HTTP timeout for Theme listing/downloads

Reported by: ahortin's profile ahortin Owned by: audrasjb's profile audrasjb
Milestone: 6.2 Priority: normal
Severity: normal Version: 3.0
Component: Themes Keywords: commit has-patch
Focuses: Cc:

Description

I just encountered an issue when trying to go to the “Add New” Theme screen in the Dashboard on my local development sites.

An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.

https://i.imgur.com/1pOA7Wf.png

  • I tried different sites with different WP versions, and all had the same issue.
  • I tried different browsers. Firefox (my default) and also Brave.
  • I tried starting Firefox in Troubleshoot mode (i.e. doesn’t load any browser add-ons)
  • I tried disabling my (Bitdefender) Anti-virus.
  • There’s no errors showing in the Console or Network tab in the browser Tools, but using the Log HTTP Requests plugin I can see that the API call is returning the following error:

http_request_failed: cURL error 28: Resolving timed out after 5000 milliseconds

If I go to the Add New Plugin screen, it works fine. I was just having having an issue on the Add New Theme screen.

After a number of different suggestions, @dd32 helpfully suggested adding the following filter which did resolve the issue:

add_filter( 'http_request_timeout', function() { return 30; } );

According to @peterwilsoncc, requests to download a Plugin set the timeout to 15 seconds, but Theme downloads do not set a timeout so it's most likely defaulting to 5 seconds.

I'm guessing this is the same for listing themes as well. As mentioned above, I didn't have any issue when listing plugins.

Could the API Timeout for listing (& downloading) Themes, please be increased to 15 seconds, just like the Plugins timeout.

Thanks.

Attachments (1)

57315.diff (445 bytes) - added by peterwilsoncc 2 years ago.

Download all attachments as: .zip

Change History (13)

@peterwilsoncc
2 years ago

#1 @peterwilsoncc
2 years ago

  • Milestone changed from Awaiting Review to 6.2

Thanks for reporting this Anthony.

In 57315.diff I've modified the HTTP request in themes_api() to use the same timeout as the HTTP request in plugins_api() -- fifteen seconds.

As consistency between interacting with the themes and plugins APIs is a good thing, I've put this on the 6.2 milestone for consideration.

#2 follow-up: @dd32
2 years ago

Now that WordPress has environment types, it might be worth increasing the intentionally-low timeouts for non-production environments too.

For example, the Plugins and Theme update checks have a ~3-5s default timeout, which could safely be increased to 15s for local/development env's. staging can probably remain as production values.

#3 in reply to: ↑ 2 @peterwilsoncc
2 years ago

Replying to dd32:

Now that WordPress has environment types, it might be worth increasing the intentionally-low timeouts for non-production environments too.

For example, the Plugins and Theme update checks have a ~3-5s default timeout, which could safely be increased to 15s for local/development env's. staging can probably remain as production values.

Are you thinking for each specific instance interacting with the wp.org API or changing the default in WP_Http::request()?

This ticket was mentioned in Slack in #core by costdev. View the logs.


22 months ago

#5 follow-up: @costdev
22 months ago

  • Keywords dev-feedback added

This ticket was discussed during the recent bug scrub. Might the proposal in comment:2 be better investigated in a separate ticket, as it targets more than just the Themes timeout?

If so, is there anything else to add to the patch here to resolve this ticket's issue?

Additional props: @SergeyBiryukov

Last edited 22 months ago by costdev (previous) (diff)

#6 in reply to: ↑ 5 @peterwilsoncc
22 months ago

  • Keywords commit added; dev-feedback removed
  • Version changed from 6.1.1 to 3.0

Replying to costdev:

This ticket was discussed during the recent bug scrub. Might the proposal in comment:2 be better investigated in a separate ticket, as it targets more than just the Themes timeout?

A separate ticket makes sense to me. That will allow for this issue to be fixed in the sorter term.

I've changed the version to 3.0.0 as that's when the timeout was extended for plugins to resolve this issue but was missed for themes. See [12742].

@audrasjb commented on PR #3924:


22 months ago
#8

I restarted the tests as E2E tests were failing.
Looks good to go, it was an unrelated timeout.

#9 @audrasjb
22 months ago

I manually restarted the tests as E2E tests were failing.
Looks good to go, it was an unrelated timeout, ironically :)

Self assigning for commit.

#10 @audrasjb
22 months ago

  • Owner set to audrasjb
  • Status changed from new to accepted

#11 @audrasjb
22 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 55188:

Themes: Increase HTTP timeout for Theme API requests.

This changeset modifies the HTTP request in themes_api() to use the same HTTP request timeout as in plugins_api(), which is 15 seconds, instead of a default value of 5 seconds.

Props ahortin, peterwilsoncc, dd32, costdev.
Fixes #57315.

Note: See TracTickets for help on using tickets.