Skip to content

W-ASAP: don't retry validation errors in fetchWasapPageData #1349

Description

@fhennig

Problem

In useWasapPageData.ts, fetchWasapPageData throws plain Errors for deterministic, non-network conditions, e.g.:

  • "No collection selected" (collection / covSpectrumCollection modes, when collectionId is undefined)
  • "No collection selected for predefined variant mode."
  • "Cannot fetch data, '<mode>' mode is not enabled."
  • Variant "<name>" not found in collection <id>. / ... is not a filterObject variant.

These are thrown synchronously before any request is made — they encode "the current page/config state doesn't have what it needs yet", not a transient failure.

useWasapPageData\'s useQuerycall doesn't set aretryoption, and theQueryClient (withQueryProvider.tsx) uses React Query's defaults (retry: 3, exponential backoff ~1s/2s/4s ≈ 7s total). Since React Query can't distinguish these thrown errors from a flaky network failure, it retries them 3 times — the UI sits in the isPending/Loading state for ~7s before flipping to isError` and finally rendering the correct message (e.g. "No collection selected").

Repro

Visit a W-ASAP page with analysisMode=collection (or covSpectrumCollection) and no collectionId in the URL, e.g.:

/swiss-wastewater/covid?locationName=Z%C3%BCrich+(ZH)&granularity=day&analysisMode=collection

The page shows a loading spinner for several seconds before showing "No collection selected", even though nothing is actually in flight for most of that time.

Proposed fix

Ideally, we would make invalid states unrepresentable so we can't even reach a state with "No ID set, this isn't valid". If we can't do that, then it would be good to distinguish between network failures (we want to retry in that case) or validation failures (no retry).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions