Repository navigation
Conversation
Pinning showed new post → old post → new post. An older validation response was landing after a newer one and overwriting `validPosts`, which made `mainDedupe` drop the current pin
A permanent self-feeding loop: ~1 REST request/second forever, with no editor interaction, because every write was a fresh array that re-entered the effect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two issues that followed the #478 fix.
apiFetchon every run, and whichever response returns last is used. This meantvalidPostscould contain pins that were no longer set andmainDedupecould drop a valid pin. The effect now sets asupersededflag in its cleanup and bails after theawait, so only the latest run can update attributes.setAttributes({ validPosts })wrote a fresh array on every validation, and because the block editor compares attributes by identity, each write counted as a change. ThemainDedupe()call that followed caused the effect to be re-entered, which fetched again. The result is several extra attribute writes and re-renders per pin. ThesetAttributescall and its dedupe pass are now skipped when validation returns what is already stored (isShallowEqual).Tested on WordPress 6.8.2, 6.9, 7.0 and 7.1.2 installs.