Skip to content

fix(extension): guard overlay refresh against out-of-order pull-context responses#7489

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-7463
Jul 20, 2026
Merged

fix(extension): guard overlay refresh against out-of-order pull-context responses#7489
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-7463

Conversation

@bitfathers94

Copy link
Copy Markdown
Contributor

fix(extension): guard overlay refresh against out-of-order pull-context responses

mountOverlay's refresh button called load() with no request-ordering
guard, so two rapid clicks issued two independent pull-context round-trips
and whichever resolved last won. Under network jitter the older click's
response could resolve after the newer one, silently leaving the overlay
showing stale data.

Move load() into a per-overlay-instance createOverlayLoader closure that
stamps each invocation with a monotonically incrementing ticket and
discards any resolved response whose ticket is no longer the latest, so
the rendered state always reflects the most recently initiated request.
Single-click behavior (loading text, error and success rendering) is
unchanged.

Closes #7463

…xt responses

mountOverlay's refresh button called load() with no request-ordering
guard, so two rapid clicks issued two independent pull-context round-trips
and whichever resolved last won. Under network jitter the older click's
response could resolve after the newer one, silently leaving the overlay
showing stale data.

Move load() into a per-overlay-instance createOverlayLoader closure that
stamps each invocation with a monotonically incrementing ticket and
discards any resolved response whose ticket is no longer the latest, so
the rendered state always reflects the most recently initiated request.
Single-click behavior (loading text, error and success rendering) is
unchanged.

Closes JSONbored#7463
@bitfathers94
bitfathers94 requested a review from JSONbored as a code owner July 20, 2026 12:34
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.39%. Comparing base (1370f24) to head (26f4458).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7489      +/-   ##
==========================================
- Coverage   91.41%   91.39%   -0.02%     
==========================================
  Files         717      717              
  Lines       73032    73032              
  Branches    21636    21635       -1     
==========================================
- Hits        66762    66751      -11     
- Misses       5227     5234       +7     
- Partials     1043     1047       +4     
Flag Coverage Δ
shard-1 30.86% <ø> (ø)
shard-2 39.73% <ø> (-0.02%) ⬇️
shard-3 36.08% <ø> (ø)
shard-4 44.85% <ø> (-0.09%) ⬇️
shard-5 34.73% <ø> (-0.05%) ⬇️
shard-6 30.65% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 2 files with indirect coverage changes

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 20, 2026
@loopover-orb

loopover-orb Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-20 12:48:35 UTC

2 files · 1 AI reviewer · no blockers · readiness 93/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This closes a real race: mountOverlay's refresh handler previously called a shared load(container, target) with no request-ordering guard, so two rapid clicks could let an older in-flight response overwrite a newer one. The rewrite moves load into a createOverlayLoader closure keyed to a per-instance monotonic ticket, discarding stale responses via `if (ticket !== latestTicket) return;` at content.js:66 — a correct, minimal fix. The added test exercises the real out-of-order path via manually-controlled promise resolvers and asserts the stale render is discarded, which is a genuine (not fabricated) regression test for this fix.

Nits — 4 non-blocking
  • content.js:63 sets body.textContent = 'Loading private context...' before the ticket staleness check exists, so if a newer load() starts and finishes first, then an older ticket's loading state could theoretically flash after — but since the loading text write happens before the await, this is actually fine in practice; still, consider guarding the loading-text write too for full consistency.
  • No test covers the case where an older request resolves with an error response after a newer one already succeeded — only the success/success ordering is tested.
  • Consider also guarding the initial 'Loading private context...' text assignment with the ticket check for full symmetry, though it's not currently reachable as a bug.
  • Add a test case for stale error responses arriving after a newer success (or vice versa) to round out branch coverage on the discard logic.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7463
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ⚠️ 20/25 Preflight is ready, but the PR body does not name the validation run.
Contributor workload ✅ 10/10 Author activity: 49 registered-repo PR(s), 30 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor bitfathers94; Gittensor profile; 49 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff introduces a per-overlay closure (createOverlayLoader) with a monotonically incrementing ticket that discards resolved responses whose ticket is no longer the latest, exactly matching the requested guard, and adds a regression test that resolves the second (newer) request before the first and asserts stale content is not rendered.

Review context
  • Author: bitfathers94
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 49 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Add validation command/output.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

Visual preview
Route Viewport Before (production) After (this PR's preview) Diff
/ desktop before /
before /
after /
after /
/ mobile before / (mobile)
before / (mobile)
after / (mobile)
after / (mobile)

Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy.

Scroll preview
Route Before (production) After (this PR's preview)
/ before / (scroll)
before / (scroll)

A short scroll-through clip (desktop) — click either thumbnail to open the full animation. Evidence for scroll-linked behavior a single screenshot can't show.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 201fe15 into JSONbored:main Jul 20, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(extension): content.js's overlay refresh button has no in-flight-request guard, can render a stale response

1 participant