fix(idl): dedupe Anchor IDL fetches during Suspense retries#1008
Conversation
|
@rogaldh is attempting to deploy a commit to the Solana Foundation Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@askov please take a look |
Greptile SummaryThis PR fixes a Suspense retry storm where the API branch of
Confidence Score: 5/5Safe to merge — the change is minimal and well-targeted, fixing a concrete duplicate-fetch regression with direct regression tests. The fix is a two-line addition to an already correct pattern (the custom branch already did this). The new No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "fix cache issue" | Re-trigger Greptile |
…idl-in-flight-dedupe # Conflicts: # bench/BUILD.md
Description
useIdlFromAnchorProgramSeedre-enters its fetch on every Suspense retry for known clusters (Mainnet/Testnet/Devnet/Simd296) because the API-branch never wrote the in-flight promise intocachedAnchorProgramPromises. Each render → a fresh/api/anchorrequest → a flood of duplicate calls. The symptom is most visible on legacy BPF-loader-owned programs (Token Program, etc.) where the address-layout<AccountDataTab>callsuseAnchorProgram(account.owner)andaccount.ownerisBPFLoader2111…— visiting/address/TokenkegQ.../securityon a local explorer would issue tens of identical/api/anchor?programAddress=BPFLoader2…requests before the first response resolved.Both branches now call a shared
recordInFlight(key, promise)beforethrow promise;, so Suspense retries short-circuit oncacheEntry.__type === 'promise'instead of refiring the request.Type of change
Screenshots
N/A — runtime fix, no UI change.
Testing
Added
app/entities/idl/model/__tests__/use-idl-from-anchor-program-seed.test.tswith two regression tests:Cluster.MainnetBeta): stubsglobal.fetch, asserts the second invocation throws the same promise andfetchis called once.Program.fetchIdl, asserts the same dedup invariant.Verified the suite fails against pre-fix code and passes after the fix:
Related Issues
N/A
Checklist
build:infoscript to update build information