Repository navigation
fix(web): bound the quorum key fetch, keep good keys, cap connect retries - #681
Merged
Merged
Conversation
…ries wasm-sdk aborts each quorum key request about 5 s in, so on a link where every request takes 6 s the connect never succeeded and the page retried forever. Quorum key requests now go through this app's fetch: 20 s of their own, the real response handed back, a good answer kept for a day and used when the service is slow or down. Connect retries back off and stop after four, with a plain message; focus or going online retries. Co-Authored-By: Claude Opus 5.5 <[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 2 minutes. View limit details
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. |
PastaPastaPasta
commented
Nov 24, 2026
PastaPastaPasta
left a comment
Owner
Author
There was a problem hiding this comment.
Verdict: approve
I read the full diff (quorum-fetch.ts, service.ts, platform-status.tsx, platform-failure.ts, tests). CI was still pending when I checked; no failures yet. Nothing blocking.
Security
- A poisoned kept entry adds no new capability. Anyone who can write this origin's localStorage can already set
forge.quorumUrl.<net>(lib/quorum-url.ts). That points every connect at a quorum service they control, and it persists. Script on the origin can also just patchfetch. Trusted mode checks proofs against whatever keys it gets, from either source, so no new verification gap opens. - Kept entries are only read when the live fetch fails, times out, returns non-OK or returns a malformed body. A good live answer always wins and overwrites the entry. Cache keys include the full service URL, so switching services in Settings never mixes them.
- Checking only
{success:true,data:object}is enough for what it's for: catching garbage, not adversaries. It also acceptsdata: [], so an empty list from a broken service replaces good keys. That only costs availability (Quorum not found, then the recovery path), never correctness.
Correctness
- Non-quorum requests:
return base(input, init)passes through untouched. The method is read frominitand then from aRequest, and anything other than GET passes through. isQuorumKeyRequest: it needs${base}/plus exactlyquorums|previous|masternodes(query, hash and trailing slash ignored). An empty base never matches.normalizeQuorumUrlstrips trailing slashes, so the user URL and the matcher agree.- Timer: cleared in
finally. The clone body is read inside the 20 s window, and the timer is cleared before the SDK reads the original. The tee'd original stream is not aborted under the SDK. Good. defineProperty(response, 'url'): an own data property shadows the prototype getter, which works for wasm-bindgen's property read. The tests cover it.- Install-once guard: correct, and it wraps the DAPI-gated fetch, so the DAPI budget still sees every request.
- Retry cap:
failuresonly resets ininstall()and cleanup, so a later success starts a fresh 4-retry budget. "Try again" afterstoppedmakes one attempt, and if that fails it stops again with no new timers. That matches the copy. visibilitychange and online only act whenretryTimer === null, so they never double-schedule.
Stale keys
- Kept keys are only used during an outage, when the alternative is no page at all. A list that misses a newer quorum fails reads with "Quorum not found".
isQuorumMiss→ reconnect → (service still down) kept keys again, bounded byQUORUM_BUDGET_MS. That is a visible failure, never a wrong read. One effect: the connect counts as ready, so the banner goes away while reads that need a newer quorum fail with quorum-miss copy. That's acceptable.
Non-blocking
lib/sdk/quorum-fetch.ts:102:now - kept.at > MAX_AGEnever expires an entry withatin the future. That can come from a planted value, or from a clock that ran ahead when the entry was kept and was corrected later. Suggest also rejectingkept.at > now + small skew. It's cheap and keeps the 24 h promise true.lib/sdk/service.ts:1339: the install-once guard captures the firstconfig.networkin thequorumBaseclosure. Afterinitialize()switches networks, the other network's quorum requests don't match, so they lose the bounded timeout and the fallback (they pass through, nothing breaks). A module-levelletbase updated on everyconnectTrustedcall would fix it. That only matters if network switching happens outside tests.keepable: consider requiring a non-empty list for/quorumsso a degraded empty answer can't overwrite good keys.- The SDK's own abort signal is dropped, so cleanup and
CONNECT_TIMEOUT_MSaborts no longer cancel an in-flight quorum fetch. It's bounded at 20 s and harmless, but worth a word in the module doc next to the 5 s note.
🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.
…eplaces them Co-Authored-By: Claude Opus 5.5 <[email protected]>
…h-bounded # Conflicts: # CHANGELOG.md
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.
Problem
When each request to the network took about 6 s, the site never loaded. wasm-sdk aborts every quorum key request (
quorums.testnet.networks.dash.org/{quorums,previous}) about 5 s in, so the trusted connect failed every time and the app retried forever, behind a banner that kept promising another try.Fix
lib/sdk/quorum-fetch.ts). Quorum key requests go through this app's fetch. The SDK's 5 s abort is ignored, and the request gets its own 20 s limit. The SDK gets back the real response, URL included. (A builtResponsehas an emptyurl, which the SDK can't parse: "url parse", then a wasm panic.)lib/sdk/service.ts): reconnects after 5, 15, 30 and 60 s, then stop. The banner then says: "It stopped retrying on its own. Check your connection, then choose Try again, or pick another quorum service in Settings." Bringing the tab back into view or the browser coming back online tries once more.Evidence
Playwright with route throttling, against static builds of master (before) and this branch (after), on real testnet. The runs were in a boat.dev sandbox, not the loaded build host. Logs are next to the screenshots in dash-ui-artifacts.
Before, 6 s per request, 300 s in:
After, 6 s per request:
After, quorum service hung, nothing kept (it stops on its own):
After, quorum service hung, keys kept:
A known limit
At 6 s per request, some Platform (DAPI) requests also hit wasm-sdk's own per-request timeout. One effect shows in the "after, slow" screenshot: "Trending this week" fails with "time range queries require protocol version 14+ … this network runs protocol version 13". The SDK fell back to a guessed protocol version when its status read timed out. Unthrottled, both builds show Trending normally. That is SDK request-timeout behaviour, outside this fix, so I'll file it as a follow-up.
Tests
quorum-fetch.test.ts: a 6 s answer arrives despite the SDK abort at 5 s; it times out at 20 s when nothing is kept; it falls back to kept keys (and their URL) while they are young enough; it keeps/previous, whosedatais an object; it never keeps a bad answer; other requests pass through untouched.service.test.ts: capped retries stop and say so.typecheck, lint, copy lint and the full vitest suite pass in a sandbox: 10,150 tests. The 3
xdiff.paritytests fail only against the sandbox's owngitbinary, in code this PR doesn't touch.🤖 Generated with Claude Code