Comfy-Org / Comfy-Org/ComfyUI_frontend

Add rollback logic for optimistic cache updates in assetsStore

Open
#8,179 0 comments 0 reactions 1 assignee Claimed by @DrJKL View on GitHub
enhancement
Dominant language
TypeScript
Stars
2k
Forks
699
Avg merge
1d 7h
Merged PRs (30d)
490

Description

## Description

Add error handling and rollback logic for optimistic cache updates in `updateAssetMetadata` and `updateAssetTags` functions in `src/stores/assetsStore.ts`.

Currently, these functions update the cache optimistically before making the network request to `assetService.updateAsset`. If the network request fails, the UI state remains out of sync with the server state.

## Enhancement

Implement rollback mechanism to:
- Capture previous asset state(s) before optimistic update
- Restore previous state(s) on network failure
- Re-throw or handle errors appropriately after rollback

## Context

Related PR: #8090
Discussion: https://github.com/Comfy-Org/ComfyUI_frontend/pull/8090#discussion_r2703161977
Requested by: @DrJKL

┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-8179-Add-rollback-logic-for-optimistic-cache-updates-in-assetsStore-2ee6d73d365081808319c26a112b357a) by [Unito](https://www.unito.io)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.