Skip to content

Commit e715a4d

Browse files
jlobue10claude
andcommitted
Retry in-flight metadata that fails under the old gateway preference
The gateway-flip retry effect only invalidated cache entries that had already failed. An entry whose fetch was still in flight was skipped — so a request started while the option was off could reject after the toggle had run, caching a failure that nothing would ever retry until remount (Bugbot, PR Chia-Network#3029). In-flight entries now get a rejection handler: if the pending fetch fails, it is invalidated and refetched under the new preference, while a result that arrives successfully is kept instead of being thrown away and refetched. Repeated toggles can stack handlers on one promise, but each retry goes through invalidate, so the worst case is a redundant refetch, not an inconsistent cache. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017NXWAjaHb9SFafLeguTHd8
1 parent bfbd0ca commit e715a4d

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

packages/gui/src/components/nfts/provider/hooks/useMetadataData.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,20 @@ export default function useMetadataData(props: UseMetadataDataProps) {
174174
// metadata fetch stayed cached here and its NFT kept looking broken
175175
// after enabling the option, until a full app reload. Only failures are
176176
// retried: successfully fetched metadata is hash-verified content and
177-
// unaffected by how it was fetched.
177+
// unaffected by how it was fetched. A fetch that is still in flight
178+
// started under the old preference and may fail because of it — after
179+
// this effect has run, nothing else would retry that failure — so it is
180+
// retried on rejection; a result that arrives successfully is kept.
178181
metadatasOnDemand.forEach((metadataOnDemand, nftId) => {
179-
if (metadataOnDemand.error) {
182+
const retry = () =>
180183
invalidate(nftId).catch((e) => {
181184
log(`Error retrying metadata for nftId: ${nftId}`, e);
182185
});
186+
187+
if (metadataOnDemand.error) {
188+
retry();
189+
} else if (metadataOnDemand.promise) {
190+
metadataOnDemand.promise.catch(retry);
183191
}
184192
});
185193
}, [ipfsGateway, invalidate /* immutable */, metadatasOnDemand /* immutable */]);

0 commit comments

Comments
 (0)