Repository navigation
Description
Describe the Bug
When using both the @payloadcms/plugin-search and @payloadcms/storage-s3 plugins together, if the search plugin is listed before the S3 storage plugin in the plugins array, image sizes are not correctly uploaded to S3:
2026-01-30.08-47-39.mp4
Root Cause Analysis
The issue appears to be related to hook execution order and how the req object is shared between plugin hooks:
-
Plugin order determines hook order: Payload processes plugins in array order, so the search plugin's
afterChangehook runs before the S3 plugin'safterChangehook. -
Search plugin modifies req: In
syncDocAsSearchIndex.js(lines 83-92 and 156-167), the search plugin'safterChangehook calls nested Payload operations:await payload.create({ collection: searchSlug, // 'search' collection data: {...}, req // <-- passes the same req object });
-
S3 plugin depends on req.file: In
getIncomingFiles.js(line 2), the cloud storage plugin reads:const file = req.file;
-
The problem: When the search plugin's hook runs first and calls
payload.createorpayload.updatewith the samereqobject, Payload clears or modifiesreq.fileduring the nested operation (since the search collection is not an upload collection). By the time the S3 plugin's hook runs,req.fileno longer contains the image size data needed for upload.
Expected Behavior
All configured image sizes should be uploaded to S3 regardless of plugin order in the config.
Actual Behavior
When search plugin is listed before S3 plugin:
- The original/full-size image is uploaded to S3
- Image sizes (thumbnail, card, etc.) are NOT uploaded to S3
- No error is thrown, making this difficult to diagnose
Link to the code that reproduces this issue
Reproduction Steps
- Clone the reproduction repository and run the development server
- Configure the
.envfile with valid S3 credentials - Navigate to
/adminand create a user account - Go to the Media collection and upload an image
- Check your S3 bucket - you will see only the original image is uploaded
- The
thumbnailandcardsizes defined in the Media collection are NOT uploaded to S3
(see video above for a reproduction)
Which area(s) are affected?
plugin: cloud-storage
Environment Info
Binaries:
Node: 24.3.0
pnpm: 10.28.1
Relevant Packages:
payload: 3.73.0
next: 15.4.11
@payloadcms/db-mongodb: 3.73.0
@payloadcms/plugin-search: 3.73.0
@payloadcms/storage-s3: 3.73.0
Operating System:
Platform: darwin
Arch: arm64
Activity
fix(plugin-cloud-storage): ensure file data persists across operations (
github-actions commentedon Feb 18, 2026
🚀 This is included in version v3.77.0
github-actions commentedon Feb 26, 2026
This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.