[tree view] Discard superseded lazy-loading responses#23005
Conversation
|
@rita-codes @michelengelen Kindly have a review on this pr. Thanks! |
Deploy previewBundle size
Check out the code infra dashboard for more information about this PR. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bea6ad3f25
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (this.lastRequestId.get(cacheKey) !== requestId) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Keep superseded expand pending until the latest fetch finishes
When the stale expand request resolves before the newer updateItemChildren request, this return makes fetchItems() complete even though the fresh request is still pending; the finally below also clears the loading state. In that ordering, handleBeforeItemToggleExpansion proceeds to expand the item and re-run selection propagation before the fresh children have been inserted, so a selected parent with selectionPropagation.descendants will not select the children loaded by the refresh. The stale response/error should be skipped without settling the user-visible expand/loading flow ahead of the current request.
Useful? React with 👍 / 👎.
bea6ad3 to
4b58291
Compare
|
Good catch, thanks for the careful read. You're right: in the ordering where the expand fetch resolves before the racing I've reworked the guard to fix this. Instead of only letting the latest-started request apply (and discarding everyone else), it now applies a response unless a newer response has already been applied, by tracking the highest applied request id per item:
Added a regression test covering the expand-resolves-first ordering with |
Fixes a race in the Tree View Pro lazy-loading plugin where a slower, older fetch could overwrite a newer response for the same item.
fetchItemChildrenapplied the awaitedgetTreeItems()response to the cache and the store unconditionally, with no request-ordering guard. BecauseupdateItemChildren(a forced refresh) bypasses theNestedDataManagerqueue and callsfetchItemChildrendirectly, it can run concurrently with an in-flight expand fetch for the same item. Whichever promise resolved last won, so an older expand response could clobber a newer refresh in both the store and the cache, and the stale data persisted until the cache TTL expired.The fix adds a per-item monotonic request id, captured before each fetch. The response (and any error) is applied only when it is still the latest request for that item. It is per-item, rather than a single global counter like the Data Grid data source, because the tree fetches many different items concurrently, so a global counter would wrongly discard valid sibling fetches.
Closes #22959
Changelog
Tree View Pro lazy loading no longer applies a stale
getTreeItems()response when a forced refresh races an in-flight expand fetch for the same item.