fix(plugin-search): serialize reindexing to prevent locale data race conditions#15917
fix(plugin-search): serialize reindexing to prevent locale data race conditions#15917ossaidqadri wants to merge 2 commits intopayloadcms:mainfrom
Conversation
Fix incorrect type name in docs/custom-components/edit-view.mdx Changed EditViewMenuItemClientProps to EditMenuItemsClientProps to match the actual exported type from the payload package. Fixes payloadcms#15898
There was a problem hiding this comment.
Pull request overview
This PR addresses a race condition in @payloadcms/plugin-search reindexing by serializing per-collection reindex work so locale create/find/update operations don’t interleave across collections within the same transaction.
Changes:
- Replaced concurrent
Promise.all(collections.map(...))reindexing with a sequentialfor...ofloop to avoid locale-related data races. - Updated docs example type name for custom
editMenuItemsclient component props.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/plugin-search/src/utilities/generateReindexHandler.ts | Serializes collection reindexing to prevent concurrent writes that can drop locale data. |
| docs/custom-components/edit-view.mdx | Fixes the documented client props type name for editMenuItems. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi @jacobsfletch @JarrodMFlesch @AlessioGr @denolfe - would appreciate a review on this PR when you have a chance. This fixes a race condition in the plugin-search reindexing that causes locale data loss when reindexing multiple collections simultaneously. The fix is straightforward - changing concurrent processing (Promise.all) to sequential processing to prevent transaction conflicts. Happy to make any adjustments if needed. Thanks! |
Description
This PR fixes a race condition in the plugin-search's reindexing functionality that caused missing locale data when reindexing multiple collections simultaneously.
Changes
Promise.allwith sequential processing of collections ingenerateReindexHandler.tsMotivation
The previous implementation used concurrent execution for collection reindexing, which led to race conditions and incomplete locale data being persisted. The issue was causing non-deterministic failures in localized search indexing.
Fixes #15884