Skip to content

Investigate concurrent uploading of images #75257

Description

@adamsilverstein

Context

Follow-up from PR #74566 comment: #74566 (comment)

The shouldPauseForSideload function in packages/upload-media/src/store/private-actions.ts pauses uploads when another upload to the same post/attachment is already in progress. This was introduced to avoid race conditions when sideloading thumbnails.

Current behavior:

  • When sideloading a thumbnail (child item with a parentId)
  • If there's already an upload in progress to the same attachment (additionalData.post)
  • The upload is paused until the other upload completes
function shouldPauseForSideload(
	item: QueueItem,
	operation: OperationType | undefined,
	select: Selectors
): boolean {
	if (
		operation !== OperationType.Upload ||
		! item.parentId ||
		! item.additionalData.post
	) {
		return false;
	}
	return select.isUploadingToPost( item.additionalData.post as number );
}

Investigation Questions

  1. Is pausing truly required? What race conditions could occur if concurrent sideloads to the same attachment are allowed?
  2. REST API handling: Can the WordPress REST API handle concurrent uploads/sideloads to the same attachment safely?
  3. Performance impact: What is the performance impact of sequential vs parallel thumbnail uploads, especially for bulk uploads (e.g., Gallery block)?
  4. Alternative approaches: Are there other ways to handle this?
    • Request queuing on the server
    • Optimistic locking
    • Retry logic for conflicts
    • Batched sideload endpoint

Expected Outcome

Document whether the pausing mechanism is necessary and, if so, explore alternatives that could improve concurrent upload performance.


Part of #74333

Metadata

Metadata

Labels

[Feature] Client Side MediaMedia processing in the browser with WASM[Status] In ProgressTracking issues with work in progress[Type] TaskIssues or PRs that have been broken down into an individual action to take

Type

No fields configured for Task.

Projects

Status
✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions