Comfy-Org / Comfy-Org/ComfyUI_frontend
Follow-up: Evaluate replacing the hand-rolled public-inclusive input asset cache with TanStack Query
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Context
Identified as a follow-up during review of PR #11873.
## Problem
The public-inclusive input asset cache introduced in PR #11873 (`getInputAssetsIncludingPublic`, `startInputAssetsIncludingPublicRequest`, `withCallerAbort`, `inputAssetsIncludingPublicRequestId`, `invalidateInputAssetsIncludingPublic`) hand-rolls ~80 lines of request deduplication, per-caller abort without cancelling the shared fetch, and counter-based cache invalidation.
`@tanstack/vue-query` (and `@tanstack/vue-virtual`) is already present in `package.json`. The same behavior can be expressed with:
```ts
export const inputAssetsIncludingPublicQuery = queryOptions({
queryKey: ['assets', 'input', { includePublic: true }],
queryFn: ({ signal }) => getAllAssetsByTag('input', true, { signal }),
staleTime: 30_000,
})
```
Cache invalidation becomes `queryClient.invalidateQueries({ queryKey: ['assets', 'input'] })` at mutation sites. Per-caller abort is handled by the subscriber model automatically. Hash lookups similarly benefit:
```ts
export const assetHashQuery = (hash: string) => queryOptions({
queryKey: ['assets', 'hash', hash],
queryFn: ({ signal }) => checkAssetHash(hash, signal),
staleTime: 60_000,
retry: 1,
})
```
This also provides automatic dedup when multiple candidates share a hash, retry on transient failure, and cross-scan caching.
## Proposed Work
- Evaluate adopting `@tanstack/vue-query` (already a workspace dependency) for the public-inclusive input asset cache.
- If adopted, replace the hand-rolled cache in `assetService.ts` with `queryOptions`-based queries and remove `withCallerAbort`, `inputAssetsIncludingPublicRequestId`, and related plumbing.
- Extend the same pattern to hash lookups in the scan pipeline.
## References
- PR: https://github.com/Comfy-Org/ComfyUI_frontend/pull/11873
- Requested by: @jaeone94
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-11898-Follow-up-Evaluate-replacing-the-hand-rolled-public-inclusive-input-asset-cache-with-3566d73d365081979036dc0ed74ebece) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.