Skip to content

fix(analytics): treat lazy distance-index 202 responses as transient #120

Closed

Description

@dborup

Problem

The fork's distance endpoint intentionally returns 202 Accepted with Retry-After while its lazy distance index is building (cmd/server/routes.go).

The generic frontend api() helper treats every successful 2xx response as final data and may cache it for the full analytics TTL. renderDistanceTab() then dereferences data.summary, which is absent from the 202 response. This can throw a TypeError and retain the incomplete {status:"building"} payload after the index is ready.

Upstream reference: Kpa-clawbot/CoreScope#2051.

Acceptance criteria

  • Never insert a 202 response into _apiCache.
  • Show a clear “building distance index” state instead of throwing.
  • Honor valid Retry-After and use a bounded fallback otherwise.
  • Maintain at most one retry chain per active Distance view.
  • Navigation cancels or invalidates old timers and responses; an older generation cannot overwrite a newer route/tab.
  • A later 200 replaces the building state and caches normally.
  • Existing analytics 503 warm-up handling remains intact.

Tests

Deterministically cover 202 → 200, cache behavior, malformed/absent Retry-After, navigation away/re-entry, out-of-order generations, and absence of console errors/unhandled rejections.

Non-goals

No distance-index/backend semantic change and no deploy.

Activity

  1. dborup commented on Sep 29, 2026

    @dborup
    OwnerAuthor

    Draft PR #133 er klar til review.

    • CI: grøn. Go Build & Test, Playwright E2E og Docker-build er success; Release, Staging og Badges er skipped.
    • Rettelse: api() cacher ikke længere 202. Distance-fanen viser en "building"-tilstand og prøver igen efter Retry-After (derefter body, så 5 s, begrænset til 1–30 s). En generationsvagt gør gamle svar og timere virkningsløse.
    • Test: 3/13 på master, 13/13 med rettelsen.
    • Browser: 202 → 200 verificeret.

    Generated by Claude Code

  2. dborup commented on Sep 30, 2026

    @dborup
    OwnerAuthor

    Fixed by #133 (merged as ad011021). Review note, not blocking: the generation guard in the error (catch) branch has no dedicated test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions