Skip to content

Fix repeated SearchProvider index rebuilds - #1350

Open
avinxshKD wants to merge 1 commit into
processing:v1from
avinxshKD:fix/issue-1249-searchprovider-codeembed
Open

avinxshKD wants to merge 1 commit into
processing:v1from
avinxshKD:fix/issue-1249-searchprovider-codeembed

Conversation

@avinxshKD

@avinxshKD avinxshKD commented Apr 21, 2026 •

Copy link
Copy Markdown

Fixes #1249

Summary

  • fetch and build the Fuse index only when the locale changes
  • reuse the index for subsequent submitted searches
  • clear stale results while a new locale index loads
  • abort stale index requests during cleanup
  • describe searchable aliases in the index type

Testing

  • npx vitest run test/components/SearchProvider.test.tsx --project DOM --reporter=verbose
  • npx eslint src/components/SearchProvider/index.tsx test/components/SearchProvider.test.tsx
  • npm run check

@avinxshKD

Copy link
Copy Markdown
Author

@ksen0 @doradocodes pls take a look, kept focused fixes as discussed (search fetch/index flow + postMessage origin hardening)

@doradocodes doradocodes linked an issue May 19, 2026 that may be closed by this pull request
@doradocodes

Copy link
Copy Markdown
Contributor

@avinxshKD From my understanding, this PR includes 2 different fixes:

  1. Fixes the issue with SearchProvider that rebuilds even when locale hasn't changed
  2. The use of * in postMessage() for iframes

If that is the case, it's important that we have 2 different issues created and 2 separate PRs to fix them. This helps keep things organized for the repo. Please update the original issue #1249 to have an accurate title+description, and create a new issue if relevant. Then have 2 PRs for the each of those issues. Thanks!

@doradocodes

Copy link
Copy Markdown
Contributor

Hi @avinxshKD, following up on this. Are you still working on it?

@Nwakaego-Ego

Copy link
Copy Markdown
Contributor

Hi @avinxshKD, this is the third follow-up on this PR. Are you still available to work on this? If you are facing any issues or are no longer able to continue, please let us know. Thank you for your work on this so far

@avinxshKD

Copy link
Copy Markdown
Author

Hi @avinxshKD, this is the third follow-up on this PR. Are you still available to work on this? If you are facing any issues or are no longer able to continue, please let us know. Thank you for your work on this so far

Im so sorry, was really busy with work and studies. Can i pick this up on this weekend?
Thankyou so much @Nwakaego-Ego

@avinxshKD
avinxshKD force-pushed the fix/issue-1249-searchprovider-codeembed branch from bfa5ccd to 0d7ec8f Compare September 24, 2026 16:11
@avinxshKD avinxshKD changed the title search: cache index per locale and tighten iframe postMessage origin Fix repeated SearchProvider index rebuilds Sep 24, 2026
@avinxshKD

Copy link
Copy Markdown
Author

@doradocodes @Nwakaego-Ego sorry this took so long. I've split the work as requested:

#1249 and this PR now cover only the SearchProvider fetch/index flow
#1605 tracks the iframe postMessage origin issue
#1606 contains the separate postMessage fix
The title and description of #1249 and this PR have also been updated to match their scope.

PTAL when get chance :p.

@avinxshKD
avinxshKD force-pushed the fix/issue-1249-searchprovider-codeembed branch from 0d7ec8f to b9c1046 Compare September 25, 2026 09:45
@Nwakaego-Ego

Copy link
Copy Markdown
Contributor

Thank you, @avinxshKD, for your work on this PR. I tested the issue again on the live websites before reviewing the fix. Typing a search term character by character did not make repeated requests. However, submitting circle and then color produced two separate requests for the same en.json file. This confirms that the problem happens when different search terms are submitted, not on every keystroke.

I also tested this PR locally:

  • submitting circle and color produced only one en.json request;
  • after switching to Spanish, submitting el color and crear produced only one es.json request;
  • both SearchProvider tests passed;

The fix works as expected in my local testing.

cc @doradocodes

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SearchProvider rebuilds the search index for every query

3 participants