Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#50711 closed defect (bug) (fixed)

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

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


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 3 years ago.
50711-extended.diff (4.0 KB) - added by azaozz 3 years ago.

Download all attachments as: .zip

Change History (6)

#1 @azaozz
3 years ago

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

3 years ago

#2 @azaozz
3 years 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 where failures are most likely and is same as after uploading new image. Can be committed now and it will start working after is fixed upstream.

Last edited 3 years ago by azaozz (previous) (diff)

#3 @azaozz
3 years ago

  • Keywords has-patch commit added

#4 @azaozz
3 years 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.