Skip to content

Fix stale response race condition in async search#453

Open
iNalgiev wants to merge 1 commit intoTarekRaafat:masterfrom
iNalgiev:fix/stale-search-race-condition
Open

Fix stale response race condition in async search#453
iNalgiev wants to merge 1 commit intoTarekRaafat:masterfrom
iNalgiev:fix/stale-search-race-condition

Conversation

@iNalgiev
Copy link
Copy Markdown

When a user types quickly, multiple async requests can be in-flight simultaneously. Previously, a slower request for an earlier query for example, a user typing "sea" quickly and continuing to "search" could see results for "sea" overwrite the correct results for "search".

Changes:

  • Added a _requestId counter to the autoComplete context that increments on each search invocation
  • After await getData() resolves, the response is discarded if a newer request was made in the meantime

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.

1 participant