Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix: restore ProductsContext.tsx + add 6 missing query-config exports (unblock ALL deploys) #605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
fix: restore ProductsContext.tsx + add 6 missing query-config exports (unblock ALL deploys) #605
Changes from all commits
4b53d0d21e467dFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consumers such as
useEnrichedFavoriteItemsandComparePagecallgetProductsByIdsduring render and depend on theproductssignal to rerun after a fetch. AftersetCachecommits, children render before this passive effect updatescacheRef, so they read the old cache, return no products, and queue the same IDs again; the fetched products only appear after another loading/timer render and incur a duplicate request. UpdatecacheRefin the cache setter (or otherwise before children render) so the render triggered byproductscan see the new entries immediately.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a saved favorite/compare/recently-viewed item points at a deleted or inactive product, the ID is requested but
fetchPromobrindProductsreturns no row, so nothing is cached here. Thefinallyblock then removes the ID fromfetchingRef, and the next render sees it missing and schedules the same request again; becausesetCachestill returns a newMapfor an empty result, this can turn a single missing product into a continuous render/network loop. Track not-found IDs or avoid updating state when no rows are returned.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because
getProductsByIdsis memoized only onqueueFetchand reads the cache through a ref, its identity does not change when the async fetch fills the cache. Consumers such asRecentlyViewedBar,RecentlyViewedPopover, and the trash views memoize their resolved products with deps like[items, getProductsByIds], so they queue the first fetch but never recompute after the provider receives the products. Include a cache version/cache dependency in the lookup API or require the provider value used by these callbacks to change with cache contents.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a product was first lazy-loaded by favorites/compare and later the catalog query returns a fresher version,
registerProductsskips it because the ID already exists. Context consumers that rely on the shared cache for price-drop calculations, seller-cart stock, or images will keep showing the stale lazy-loaded record until a full reload even though the page-level query has newer data. Registration should replace existing entries when the incoming product differs.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
ProductCardprefetches on hover,usePrefetchProductuses this prefix to cacheproductService.fetchProductById(productId), but the detail page'suseProductreads['promobrind-product', id]. With the new'products'prefix, the hover prefetch is stored under a key no detail consumer uses, so navigating to a hovered product still performs the full detail fetch instead of reusing the warmed cache.Useful? React with 👍 / 👎.
Uh oh!
There was an error while loading. Please reload this page.