akiomik / akiomik/nosvelte

A refetch restarts accumulation from an empty seed, collapsing list data

Ouverte
#82 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
bug
Langage dominant
TypeScript
Étoiles
29
Forks
3
Merge moyen
3 h 5 min
PR mergées (30 j)
11

Description

`useReq()` builds its observable once (`src/lib/stores/useReq.ts:42`) and subscribes
to it inside `queryFn` (`:52-69`). Every fetch attempt therefore re-subscribes,
which restarts `scanArray()` / `scanLatestEach()` from their seeds, and the value
the promise resolves with overwrites whatever the cache had accumulated.

Verified on `main` (609f8ed): with a list holding `['a1','a2']`, a
`refetchQueries` followed by a single event left `$data === ['b1']`.

The mock relay showed **no second REQ** — rx-nostr dedupes the identical subId
while the first subscription is still open — so the second subscription only sees
events from that point on. The collapse is not even compensated by re-fetching the
backlog.

This is reachable in normal use: `refetchOnWindowFocus` is left at its default
`true` (filed separately), so returning to the tab more than `staleTime` after a
request settles is enough.

## Direction

The accumulation strategies used here (dedupe by id, latest per pubkey, latest per
address) are all idempotent and monotonic — replaying an event changes nothing, and
a newer event can only add or replace. If a re-request feeds the *existing*
accumulator instead of a fresh one, this class of failure cannot occur: a refetch
can only grow or update the result.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Start in src/lib/stores/useReq.ts at lines 42 and 52-69, then trace how scanArray() and scanLatestEach() receive their seeds across subscriptions. Reproduce the refetchQueries scenario with accumulated list data and verify that a refetch preserves existing items while still accepting later events; the result should no longer collapse to only post-refetch events.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
typescript
Domaine
frontend
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
Calme
Clarté
Clairement spécifiée
Accessibilité débutants
72/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.