Skip to content

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

Merged
chrisgervang merged 4 commits into
visgl:masterfrom
SahinurDEV:fix/async-prop-stale-release
Nov 2, 2026
Merged

chrisgervang merged 4 commits into
visgl:masterfrom
SahinurDEV:fix/async-prop-stale-release

Conversation

@SahinurDEV

@SahinurDEV SahinurDEV commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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)

Behavior change

  • A stale async prop result is now dropped before _onResolve, so a stale data load no longer calls onDataLoad. That data is never applied, so the callback only fires for the load that actually wins.

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

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge; no blocking issue was found.

Summary

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

  • Older async prop results are dropped before they can affect the current value.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Promise resolves] --> B{Component still active?}
  B -->|No| C[Ignore result]
  B -->|Yes| D{Newer load already completed?}
  D -->|Yes| C
  D -->|No| E[Release previous value and transform result]
  E --> F[Update prop and call resolve callback]
Loading

Reviews (4) · Last reviewed commit: "Merge branch 'master' into fix/async-pro..." · Reviewed by Greptile

@coveralls

coveralls commented Oct 30, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 84.373% (-0.001%) from 84.374% — SahinurDEV:fix/async-prop-stale-release into visgl:master

@chrisgervang chrisgervang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, this looks right. Skipping _postProcessValue for a stale result stops the prop type's release from destroying the value that's actually in use. I ran the new test locally: it fails without the fix and passes with it.

One behavior change to call out: a stale data load no longer calls onDataLoad. I think that's correct, since that data never gets applied, but please mention it in the description.

@SahinurDEV

Copy link
Copy Markdown
Contributor Author

Thanks for testing it! Good point, I added a "Behavior change" section to the description noting that a stale data load no longer calls onDataLoad, since its result is never applied.

@chrisgervang
chrisgervang merged commit 4e93117 into visgl:master Nov 2, 2026
8 checks passed
chrisgervang pushed a commit that referenced this pull request Nov 3, 2026
@chrisgervang

Copy link
Copy Markdown
Collaborator

Released in deck.gl 9.4.2. Thanks @SahinurDEV!

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

Labels

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)

3 participants