Skip to content

fix: guard store grid image load callback against destroyed container#2002

Merged
willeastcott merged 1 commit intomainfrom
fix/store-grid-image-load-race
Apr 13, 2026
Merged

fix: guard store grid image load callback against destroyed container#2002
willeastcott merged 1 commit intomainfrom
fix/store-grid-image-load-race

Conversation

@willeastcott
Copy link
Copy Markdown
Contributor

Summary

  • Fixes a race condition in the asset store grid where rapidly switching between store tabs (PlayCanvas, Sketchfab, My Assets) causes a TypeError: Cannot read properties of null (reading 'appendChild').
  • itemsContainer.clear() destroys grid item containers while thumbnail images are still loading. When the load callback fires on a destroyed container, Container.append() crashes because the backing DOM has been nulled. A gridItem.destroyed guard prevents the stale callback from executing.

When rapidly switching between store tabs, itemsContainer.clear() destroys
grid items while their thumbnail images are still loading. The late load
callback then crashes calling appendChild on the nulled DOM. Adding a
destroyed check prevents the race.

Made-with: Cursor
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
editor Ready Ready Preview, Comment Apr 13, 2026 3:16pm

Request Review

@willeastcott willeastcott requested a review from Copilot April 13, 2026 15:17
@willeastcott willeastcott self-assigned this Apr 13, 2026
@willeastcott willeastcott added the bug Something isn't working label Apr 13, 2026
@willeastcott willeastcott merged commit 99a6979 into main Apr 13, 2026
10 checks passed
@willeastcott willeastcott deleted the fix/store-grid-image-load-race branch April 13, 2026 15:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a race condition in the asset store picker grid where thumbnail load events can fire after the grid item container has been destroyed (e.g., when rapidly switching store tabs), leading to a DOM append on a nulled container.

Changes:

  • Added a gridItem.destroyed early-return guard inside the thumbnail load handler to prevent stale UI mutations after teardown.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants