Skip to content

fix(web): bound the quorum key fetch, keep good keys, cap connect retries - #681

Merged
PastaPastaPasta merged 3 commits into
masterfrom
fix/web-quorum-fetch-bounded
Nov 24, 2026
Merged

PastaPastaPasta merged 3 commits into
masterfrom
fix/web-quorum-fetch-bounded

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

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

  • Bounded quorum fetch (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 built Response has an empty url, which the SDK can't parse: "url parse", then a wasm panic.)
  • Fallback to kept keys. A good answer is kept in localStorage for 24 h (the keys are public). When the service is slow, down or answers non-OK, the kept answer is used.
  • Capped retry with backoff (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.

Scenario Before After
Every external request takes 6 s never ready in 300 s, banner from 7.5 s, retrying forever ready at 13.3 s
Quorum service never answers, nothing kept (retries forever) banner at 21 s, stops retrying at 212 s
Quorum service never answers, keys kept from an earlier visit (never loads) ready at 21.2 s
No throttling ready at 2.3 s ready at 2.3 s, page identical

Before, 6 s per request, 300 s in:

before

After, 6 s per request:

after slow

After, quorum service hung, nothing kept (it stops on its own):

after hang

After, quorum service hung, keys kept:

after cached

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, whose data is 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.parity tests fail only against the sandbox's own git binary, in code this PR doesn't touch.

🤖 Generated with Claude Code

…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]>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f3e5640a-ed14-466e-8a3c-75f58b4efb5c
Commits

Reviewing files that changed from the base of the PR and between 515059f and 099627f.

Files selected for processing: 7

  • CHANGELOG.md
  • forge-web/components/ui/platform-status.tsx
  • forge-web/lib/sdk/quorum-fetch.test.ts
  • forge-web/lib/sdk/quorum-fetch.ts
  • forge-web/lib/sdk/service.test.ts
  • forge-web/lib/sdk/service.ts
  • forge-web/lib/view/platform-failure.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 patch fetch. 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 accepts data: [], 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 from init and then from a Request, and anything other than GET passes through.
  • isQuorumKeyRequest: it needs ${base}/ plus exactly quorums|previous|masternodes (query, hash and trailing slash ignored). An empty base never matches. normalizeQuorumUrl strips 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: failures only resets in install() and cleanup, so a later success starts a fresh 4-retry budget. "Try again" after stopped makes one attempt, and if that fails it stops again with no new timers. That matches the copy. visibilitychange and online only act when retryTimer === 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 by QUORUM_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

  1. lib/sdk/quorum-fetch.ts:102: now - kept.at > MAX_AGE never expires an entry with at in 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 rejecting kept.at > now + small skew. It's cheap and keeps the 24 h promise true.
  2. lib/sdk/service.ts:1339: the install-once guard captures the first config.network in the quorumBase closure. After initialize() 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-level let base updated on every connectTrusted call would fix it. That only matters if network switching happens outside tests.
  3. keepable: consider requiring a non-empty list for /quorums so a degraded empty answer can't overwrite good keys.
  4. The SDK's own abort signal is dropped, so cleanup and CONNECT_TIMEOUT_MS aborts 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.

@PastaPastaPasta
PastaPastaPasta merged commit 4e2e476 into master Nov 24, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant