WordPress.org

Make WordPress Core

#50711 closed defect (bug) (fixed)

REST API, Media: Fix retrying of post-processing of edited images

Reported by: azaozz Owned by: azaozz
Milestone: 5.5 Priority: normal
Severity: normal Version: 5.5
Component: Media Keywords: has-patch commit
Focuses: rest-api Cc:

Description

When an image is edited in the block editor, and the server runs out of resources while post-processing it, the retry request(s) to /wp/v2/media/${ attachmentId }/post-process don't "kick-in".

Attachments (2)

50711.diff (874 bytes) - added by azaozz 15 months ago.
50711-extended.diff (4.0 KB) - added by azaozz 15 months ago.

Download all attachments as: .zip

Change History (6)

#1 @azaozz
15 months ago

Mostly caused by mismatch (missing slash) of the path in image-editor.js. Opened https://github.com/WordPress/gutenberg/pull/24081 to fix it. Will also need to set the X-WP-Upload-Attachment-ID HTTP header in WP_REST_Attachments_Controller::edit_media_item().

@azaozz
15 months ago

#2 @azaozz
15 months ago

Ideally it can be like 50711-extended.diff, the new attachment post is created and the X-WP-Upload-Attachment-ID header is set before any edits are applied to the image. Then it can retry on all possible failures. However there are few caveats:

  • Standard API errors cannot be HTTP 500 or they will trigger retries.
  • Currently on the js side it can only retry to create image sub-sizes. Would need to handle cases (repeat the request) if the server fails while cropping or rotating the image.

Lets improve this in 5.6.

For now lets handle "server crashes" when creating the sub-sizes for the edited image, see 50711.diff. This is the same as after uploading new image. Can be committed now and it will start working after https://github.com/WordPress/gutenberg/pull/24081 is fixed upstream.

Version 1, edited 15 months ago by azaozz (previous) (next) (diff)

#3 @azaozz
15 months ago

  • Keywords has-patch commit added

#4 @azaozz
15 months ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In 48525:

REST API, Media: Add X-WP-Upload-Attachment-ID HTTP header to enable retrying of post-processing of edited images if the server runs out of resources. This is the same as after uploading a new image, will do up to five additional requests to let the server create all image sub-sizes.

Fixes #50711.

Note: See TracTickets for help on using tickets.