New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that only the latest promise updates the autocompleter state #7318

Merged
merged 1 commit into from Jun 15, 2018

Conversation

Projects
None yet
3 participants
@notnownikki
Member

notnownikki commented Jun 15, 2018

Fixes: #7317

Description

Multiple promises can be resolving when using an autocompleter, and network conditions can determine which one actually gets to update the state. We only want the most recently created promise to update the state.

This keeps track of the most recent (or, active) promise, and only processes the result if the promise is still the most recent one.

How has this been tested?

I followed the following:

  1. put "sleep(5)" on the server side to simulate a slow network.
  2. set up two users with the following usernames and real names: admin - "Jamjam", james - "James Jamison"
  3. Carry out the typing test as described in #7317

The list of users updated correctly, and slow API requests didn't end up interfering with each other.

Types of changes

Bug fix

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@notnownikki notnownikki requested a review from brandonpayton Jun 15, 2018

@brandonpayton

brandonpayton approved these changes Jun 15, 2018 edited

The code looks good to me and eliminates the race condition experience we've seen with the user completer.

Thank you!

@notnownikki notnownikki merged commit ae117ef into master Jun 15, 2018

2 checks passed

codecov/project 46.68% (+<.01%) compared to a9c3392
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

Luehrsen added a commit to luehrsenheinrich/gutenberg that referenced this pull request Jun 16, 2018

@mtias mtias added this to the 3.1 milestone Jun 20, 2018

@mtias mtias deleted the fix/latest-promise-only-in-autocompleter branch Jun 20, 2018

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