akiomik / akiomik/nosvelte

useEventList()/useMetadataList() send a REQ that can only return nothing for an empty input

Aberta
#79 0 comentários 0 reações 0 responsáveis Ver no GitHub
bug
Linguagem predominante
TypeScript
Estrelas
29
Forks
3
Merge médio
3h 5min
PRs com merge (30d)
11

Descrição

Two hooks derive `limit` from the length of their input array:

- `src/lib/stores/useEventList.ts:21` — `{ ids, limit: ids.length }`
- `src/lib/stores/useMetadataList.ts:21` — `{ kinds: [0], authors: pubkeys, limit: pubkeys.length }`

Given an empty array this sends `["REQ", subId, {"ids":[],"limit":0}]`.
rx-nostr's `normalizeFilter` keeps `limit: 0` (`rx-req.ts:229`), and `use()`'s
guard `filter(({ filters }) => filters.length > 0)` counts *filters*, not ids, so
the REQ goes out to every relay. It can only ever return nothing.

An empty input is a normal thing for a caller to hold briefly — an id list derived
from another query that has not resolved yet, or a contact list that is still
loading.

Determined by code reading, with the `normalizeFilter` behaviour checked in the
installed rx-nostr source.

## Direction

Short-circuit on an empty input: return the empty result without sending a REQ.

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.