persistQueryClientSubscribe drops the persistQueryClientSave promise, causing unhandled rejections when persisting fails
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 62/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- frontend
Direzione di ricerca
Start by locating persistQueryClientSubscribe and comparing its save path with the existing restore-side error handling described in the issue. Reproduce the rejected persister case with the reported test scenario, then verify the chosen error-handling behavior prevents unhandled rejections and is covered by a test; also check the IndexedDB documentation example if that option is selected.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
persistQueryClientSubscribe calls persistQueryClientSave(props) on every cache event, but it doesn't handle the returned promise. So if saving fails, I get an unhandled promise rejection on each cache update.
I noticed this while reading the code and confirmed it with a test. It can happen with a custom persister like the IndexedDB example in the docs, because set() from idb-keyval can reject, for example with QuotaExceededError or DataCloneError. It can also happen with the built-in persisters if a dehydrateOptions callback like shouldDehydrateQuery throws.
Small repro:
const queryClient = new QueryClient()
persistQueryClientSubscribe({
queryClient,
persister: {
persistClient: () => Promise.reject(new Error('quota exceeded')),
restoreClient: () => undefined,
removeClient: () => undefined,
},
})
queryClient.setQueryData(['a'], 1) // -> unhandled rejection
This affects all the persist providers, since they all use persistQueryClientSubscribe. That includes Vue's clientPersister when it's used with persistQueryClient().
The restore side already catches errors and logs a warning in dev (#8969), but the save side doesn't. I know error handling has mostly been left to the persister (#3527), so I'm not sure which way you'd prefer:
- catch it in
persistQueryClientSubscribeand log in dev, same as restore - keep the code as is, and add a
try/catchto the IndexedDB example in the docs
I'm happy to send a PR for either one.
- Lingua principale
- TypeScript
- Stelle
- 50.4k
- Fork
- 4.2k
- Merge medio
- 21h 23m
- PR unite (30g)
- 274
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/query
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TanStack/query#11358 · 2 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TanStack/query#11106 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
TanStack/query#11642 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 74/100
TanStack/query#11639 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TanStack/query
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
StabilityNexus/Fate-EVM-Frontend#153 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
code-yeongyu/oh-my-openagent#9039 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Tencent/teamai-cli#862 ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue hacktoberfest redis
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
libredb/libredb-studio#1164 ·
I maintainer di solito rispondono entro 1 giorno
-
flake
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno