Skip to content
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

Search: Fix race condition for API responses #19477

Merged
merged 5 commits into from
Apr 9, 2021

Conversation

jsnmoon
Copy link
Member

@jsnmoon jsnmoon commented Apr 8, 2021

Changes proposed in this Pull Request:

Currently, it's possible for stale API responses to overwrite newer API responses. As a fix, this PR makes two changes:

  1. Attaches a client-generated sequential ID to each API response to determine whether or not to evict the existing response stored in the Redux store.
  2. Prevents the getResults denounce from being flushed upon SearchApp mounting.

Does this pull request change what data or activity we track or use?

No.

Testing instructions:

  • Apply this change to your site with a Jetpack Search subscription.
  • Directly navigate to a search page (e.g. ?s=apples).
  • Ensure that only one search API response is recorded in the browser network console.
  • Ensure that an older API response never overwrites a newer API response; this might be hard to reproduce. To make this easier, you can apply this patch to add some randomized delay to each API response.

@jsnmoon jsnmoon requested a review from a team April 8, 2021 21:21
@jsnmoon jsnmoon self-assigned this Apr 8, 2021
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello jsnmoon! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D59942-code works as expected before merging this PR. Once this PR is merged, please commit the changes to WP.com. Thank you!
This revision will be updated with each commit to this PR

@jsnmoon jsnmoon added the [Type] Bug When a feature is broken and / or not performing as intended label Apr 8, 2021
@github-actions github-actions bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Apr 8, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Apr 8, 2021

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: April 13, 2021.
  • Scheduled code freeze: April 6, 2021.

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Apr 8, 2021
@jsnmoon jsnmoon removed the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Apr 8, 2021
@jsnmoon jsnmoon added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! [Status] In Progress and removed [Status] Needs Team Review [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Apr 9, 2021
Copy link
Contributor

@bluefuton bluefuton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Tests out well.

@bluefuton bluefuton added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Needs Team Review labels Apr 9, 2021
@jeherve jeherve added this to the jetpack/9.7 milestone Apr 9, 2021
@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Apr 9, 2021
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tests well for me. 🚢

@jsnmoon jsnmoon merged commit abb24d1 into master Apr 9, 2021
@jsnmoon jsnmoon deleted the fix/search-api-race-condition branch April 9, 2021 20:17
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Apr 9, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Apr 9, 2021

Great news! One last step: head over to your WordPress.com diff, D59942-code, and commit it.
Once you've done so, come back to this PR and add a comment with your changeset ID.

Thank you!

@jsnmoon
Copy link
Member Author

jsnmoon commented Apr 9, 2021

🚢 r224082-wpcom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Search For all things related to Search [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Touches WP.com Files [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants