Skip to content

fix(core): ignore stale async prop loads before releasing the current value - #10828

Open
SahinurDEV wants to merge 1 commit into
visgl:masterfrom
SahinurDEV:fix/async-prop-stale-release
Open

SahinurDEV wants to merge 1 commit into
visgl:masterfrom
SahinurDEV:fix/async-prop-stale-release

Conversation

@SahinurDEV

@SahinurDEV SahinurDEV commented Oct 10, 2026 •

Copy link
Copy Markdown

Closes #10827

Background

When an async prop changes while an earlier load is still pending and the loads resolve out of order, ComponentState._watchPromise runs _postProcessValue on the stale result before _setAsyncPropValue rejects it by load count. That calls the prop type's release hook on the currently active value (e.g. destroys the active IconLayer.iconAtlas texture) and transforms a value that is then thrown away.

Change List

  • ComponentState: discard stale promise results before post processing
  • Unit tests (verified with yarn lint and vitest --project headless test/modules/core test/modules/layers)

Note

Medium Risk
Touches core async prop lifecycle and resource release timing; behavior change is narrowly scoped to discarding stale loads but affects all components using async props with release/transform.

Overview
Fixes a race when the same async prop is loaded multiple times and promises resolve out of order. Previously, a slower (stale) resolution still ran _postProcessValue before _setAsyncPropValue dropped it, so the prop type’s release hook could tear down the currently active resolved value (e.g. an icon atlas texture) even though that result was never applied.

ComponentState._watchPromise now bails out when loadCount < resolvedLoadCount before post-processing, so stale completions skip release/transform entirely. A new unit test covers the out-of-order case: newer value wins, stale completion does not change state, release, or transform.

Reviewed by Cursor Bugbot for commit 4bba4c4. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

ComponentState now discards stale promise results before they can release the current value or transform discarded data.

  • Older async results are skipped before resource hooks run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Promise resolves] --> B{Component still active?}
  B -->|No| C[Discard result]
  B -->|Yes| D{Older than accepted load?}
  D -->|Yes| C
  D -->|No| E[Release previous value and transform result]
  E --> F[Store value and notify listeners]
Loading

Reviews (1) · Last reviewed commit: "fix(core): ignore stale async prop loads..." · Reviewed by Greptile

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Stale async iconAtlas completion destroys the currently active texture (v9.4.0)

1 participant