Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

persistQueryClientSubscribe drops the persistQueryClientSave promise, causing unhandled rejections when persisting fails

Abierto
#11,663 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
62/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript
Área
frontend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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:

  1. catch it in persistQueryClientSubscribe and log in dev, same as restore
  2. keep the code as is, and add a try/catch to the IndexedDB example in the docs

I'm happy to send a PR for either one.

Lenguaje dominante
TypeScript
Estrellas
50.4k
Forks
4.2k
Merge medio
21 h 23 min
PR fusionados (30 d)
274

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TanStack/query

Todos los issues de TanStack/query

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.