Skip to content

fix: prevent bulk operation data loss and surface upload failures - #18266

Open
jenslys wants to merge 1 commit into
payloadcms:3.xfrom
jenslys:fix/3x-bulk-transaction-and-upload-hooks
Open

jenslys wants to merge 1 commit into
payloadcms:3.xfrom
jenslys:fix/3x-bulk-transaction-and-upload-hooks

Conversation

@jenslys

@jenslys jenslys commented Sep 23, 2026

Copy link
Copy Markdown

Summary

  • process bulk update and delete document pipelines sequentially so queries do not overlap on the request's shared transaction client
  • fix the bulk-delete map(async ...) path, which eagerly started every delete even when bulkOperationsSingleTransaction was enabled
  • preserve bulk-upload forms when fetch() or response parsing fails instead of swallowing the exception and reporting the file as saved
  • dispatch typed bulk-upload lifecycle events so integrations can prepare files asynchronously and observe request/response failures

Fixes #16333.
Related to #16075 and #16076.

Impact

The concurrent database path triggers pg's deprecated nested client.query() behavior today. It can also silently lose localized writes or deletes; pg@9 will reject it outright.

The upload path currently swallows non-JSON edge responses such as an HTML 429, then removes the failed form and can report success. This change keeps the file in the failed set, shows an error, and exposes status/content-type context to an event listener.

The file-preparation event is additive: with no listener, Payload uses the original files unchanged. A synchronous listener may assign event.detail.preparation to a Promise<File[]>, which Payload awaits before creating forms.

Why these changes share a PR

A downstream integration currently needs both payload and @payloadcms/ui changes in one immutable prerelease. Payload's internal packages use exact peer versions, so separate prereleases cannot be combined safely. The commits can be split if maintainers prefer once an internal build is available.

Verification

  • pnpm --filter payload run build
  • pnpm --filter @payloadcms/ui run build:types
  • vitest run --project unit packages/ui/src/elements/BulkUpload/FormsManager/index.spec.ts — 3 passed
  • pnpm run test:int:postgres test/database/int.spec.ts -t 'bulk operations in' — 4 passed
  • the same PostgreSQL regression test against unmodified 3.x fails 3 of 4 cases: default bulk update/delete and bulk delete with bulkOperationsSingleTransaction enabled

Could a maintainer publish an internal prerelease from this PR so the downstream app can replace its Bun patches with one immutable package version?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants