A stream error just after the first event resolves the query while reporting 'error'
- Lenguaje dominante
- TypeScript
- Estrellas
- 29
- Forks
- 3
- Merge medio
- 3 h 5 min
- PR fusionados (30 d)
- 11
Descripción
`useReq()` defers its promise resolution to a microtask
(`src/lib/stores/useReq.ts:60-70`):
```ts
next: (v) => {
latest = v;
if (fulfilled) {
queryClient.setQueryData(queryKey, v);
} else {
fulfilled = true;
queueMicrotask(() => resolve(latest));
}
},
```
`fulfilled` is set *before* the resolution actually happens. If the stream errors
between that first `next` and the microtask, the error branch (`:88-97`) sees
`fulfilled === true` and therefore does **not** reject:
```ts
error: (e) => {
console.error(e);
status.set('error');
error.set(e);
if (!fulfilled) { reject(e); fulfilled = true; }
}
```
The microtask then resolves the query successfully. The result is a state no
consumer can act on: the query is `success` and `.data` holds the first value,
while `.status` reports `'error'` and `.error` is populated. Because every component
checks `{#if $error}` first, the data is not shown.
Determined by code reading; not reproduced.
## Direction
The three stores are updated independently, which is what allows the combination to
exist at all. A single value carrying the whole state makes it unrepresentable.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.