Skip to content

Conversation

@til
Copy link

@til til commented Feb 2, 2025

Before, a slow server response arriving after the response to a later request would cause outdated results to be rendered.

Example sequence of events:

  1. user types "ab", request for q=ab starts
  2. user types "cd", request for q=abcd starts
  3. response for q=abcd arrives and is rendered
  4. response for q=ab arrives and should be discarded

I've reproduced it locally with a test server that echos the search with "You searched for ..." and artificially delays the response to q=ab by 2s. At the end of the video, it shows "You searched for ab", but it should show "You searched for abcd".

out-of-order


Give me a hint how to test this with cypress and I can give it a try. Something with intercept returning a promise?

Somewhat related to #137 .

Before, a slow server response arriving after the response to a later
request would cause outdated results to be rendered.

Example sequence of events:

1. user types "ab", request for q=ab starts
2. user types "cd", request for q=abcd starts
3. response for q=abcd arrives and is rendered
4. response for q=ab arrives and should be discarded
@netlify
Copy link

netlify bot commented Feb 2, 2025

Deploy Preview for stimulus-autocomplete canceled.

Name Link
🔨 Latest commit df42d0f
🔍 Latest deploy log https://app.netlify.com/sites/stimulus-autocomplete/deploys/679ffe70e06f8300084e3931

@til
Copy link
Author

til commented Feb 2, 2025

I should add that I've experienced this behaviour in production on a server with high variability in search response time (20ms-1000ms) and data-autocomplete-delay-value set to 100. Without these two factors, you might never see it.

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