Repository navigation
fix(core): ignore stale async prop loads before post-processing - #10846
Muhtasim-Munif-Fahim wants to merge 1 commit into
Conversation
When an async prop changes while an earlier load is pending and the loads resolve out of order, the stale completion ran _postProcessValue before _setAsyncPropValue discarded it. That called the prop type's release hook on the current value, e.g. destroying the active IconLayer iconAtlas texture. Return early when a more recent load has already resolved. Fixes visgl#10827
|
| // The newer load resolves first | ||
| newerLoad.resolve('newer'); |
There was a problem hiding this comment.
Older-first behavior lacks coverage
The new test only covers the newer load finishing first. It would also pass with loadCount < asyncProp.pendingLoadCount, which would wrongly discard an older result while the newer load is still pending.
Add an older-first case that checks the older value is transformed and shown, loading stays true, and the newer result later replaces it. This protects the behavior the PR explicitly preserves.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Closes #10827
Background
A stale async completion ran
_postProcessValuebefore_setAsyncPropValuediscarded it, so the prop type'sreleasehook destroyed the current value (e.g. the activeiconAtlastexture). Stale results are now dropped first. Unlike the guard in the issue (loadCount !== pendingLoadCount), this only skips loads older than the last resolved one, so an older load that resolves while a newer one is still pending is accepted as before.Change List
ComponentState._watchPromise: return early if a newer load already resolvedTests:
vitest --project headless test/modules/core test/modules/layers→ 701 passed; the new test fails without the fix. Biome clean.AI assistance was used to help find the cause, write the patch, and run tests; I reviewed the change.
Note
Medium Risk
Touches core async prop lifecycle and resource release timing; fix is localized but affects all components using async props with
release/transform.Overview
Fixes a race where an out-of-order async prop resolution still ran
_postProcessValue(includingreleaseon the live resolved value) even though_setAsyncPropValuewould later ignore that load. Stale completions are now dropped before post-processing whenloadCountis older thanresolvedLoadCount, so in-use resources (e.g. textures) are not torn down by a late promise.The guard is narrower than “load still pending”: an older load that finishes while a newer one is still in flight can still apply, matching existing behavior. A unit test covers newer-then-older resolution and asserts the current value is unchanged and
release/transformare not run for the stale result.Reviewed by Cursor Bugbot for commit 7afe5bb. Bugbot is set up for automated code reviews on this repo. Configure here.