Repository navigation
fix(web): retry a composite read on a stale contract, and refetch only the contracts that moved - #394
Merged
Merged
Conversation
…de stale The repo chrome reads through documents.composite (a forge-core repo page with sub-queries over forge-collab, forge-community and DPNS), which had no stale-contract retry. With a v1 seed, a v2 issue or patch in a sub-query failed the whole read with 'trailing bytes ... refetch the contract' (a wasm-bindgen object in the browser), so the releases, issue and PR pages of an updated repo showed the error on every fresh load; the background seeded-version check refetched the contracts only after the page had given up, which is why Try again worked. retryOnStaleContract now takes every contract a read touches (the error does not name the stale one), refreshes each and retries once when any was. The composite read and the count, sum and ranked aggregates go through it too. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…its refetch revalidateSeeded took a contract out of seeded before refetching it, so a read failing meanwhile on a type an update added found it neither seeded nor refreshable and gave up, and one failing on a newer document fetched it a second time. The check now refreshes through refreshStale, which registers the refetch for those reads to join. A seeded contract already at the failed document's version is left alone, so a composite does not refetch its current contracts. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…etwork moved past A composite's stale-contract error names a document version, but not which contract it belongs to, and versions of different contracts do not compare. Comparing it with each contract's own version refetched current contracts, and kept refetching them: a refreshed contract below the document's version stayed 'outran' for the whole window (10 failing reads, 10 getDataContract for forge-core), and with no snapshot every fetched contract was refetched on the first failure. The stale handler now receives every contract a read used. One contract keeps the cheap path. Several are placed with one getDataContractsLatestVersions request (shared by reads failing together): a contract is refreshed only when the network's version is past the one held (seeded, or fetched by a recent refresh) and, for a newer document, at least that document's version; one held at no known version only for a newer document. A contract refreshed within the window is joined, so a read that failed while the seeded-version check refetched it still retries. A 'document type not found' composite now refreshes only the seeded contracts that moved. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 33 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
#367 added a refetch-and-retry for reads that fail because the web app holds a contract older than the network's. In a real browser it still failed after UPDATE-1 (#390) took the sakura contracts to version 2. With the version-1 snapshot seeded, a fresh load of a repo page that shows a version-2 document said "That read did not land … trailing bytes … refetch the contract". "Try again" worked a few seconds later; a reload failed again.
Root cause
lib/repo/chrome.ts. It goes throughqueryComposite(lib/sdk/composite.ts), which runs sub-queries across forge-core, forge-collab, forge-community and DPNS. That path never calledretryOnStaleContract, so it rejected with the stale-contract error whilerevalidateSeededrefetched the contracts in the background. Those were the threegetDataContractcalls in the network log, and the reason "Try again" later worked.revalidateSeededtook a contract out ofseededbefore refetching it. A read failing in that window on a type an update added gave up. One failing on a newer document fetched the contract a second time.Fix
retryOnStaleContracttakes several contract ids, because the error doesn't name the stale contract. It refreshes each one and retries once if any was refreshed. The composite read uses it, and so do count, grouped count, sum and ranked reads.revalidateSeededrefreshes throughrefreshStale, so a read failing in that window joins the refetch already in flight.No refetch storm. The stale handler receives every contract the failed read used.
getDataContractsLatestVersionslookup. It refetches only contracts whose network version is past what this tab holds (the seeded version, or one a recent refresh fetched), and for a newer document, only those at or above the document's version.An independent review showed the earlier per-contract logic refetching an unchanged contract on every failure (10 failures, 10 fetches). Tests now pin that down.
Evidence
query.test.ts,service-stale.test.tsand a newcomposite.test.ts. They cover the composite retry, the race, the storm cases (seeded and unseeded, 10 failures, the moved contract refetched once), a composite with an unknown type, and "one contract costs no version lookup". The fix cases fail on master, and the storm cases fail with the per-contract logic.rc1u-muutofz9/releasesrc1u-muutofz9/issues/1rc1u-muutofz9/pulls/2forge-v2-demoAfter the fix, each of the three rc1u pages makes three
getDataContractrequests (the three changed contracts) and twogetDataContractsLatestVersionsper load. Full vitest passes 5953 tests; tsc, lint and copy lint pass.#390 already ships the version-2 snapshot, so this matters for tabs left open across an update and for the next in-place update.
🤖 Generated with Claude Code