resource.reload() while params is in error switches the resource to 'idle' instead of retrying
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- angular, typescript
Línea de trabajo
Empieza en packages/core/src/resource/resource.ts, especialmente en ResourceImpl.reload() y el cálculo del estado alrededor de las líneas citadas en el issue. Lee las pruebas existentes de resource y añade un caso de regresión para un error de params seguido de reload(). Se considerará terminado cuando reload no indique éxito sin ejecutar el loader y el resource conserve un estado de error coherente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
When a resource's params function throws (for example a thrown validation error, or mirroring an
upstream resource's error), the resource correctly reports status() === 'error'. Calling reload()
in that state breaks the resource:
reload()returnstrue, but the loader never runs,status()switches from'error'to'idle',error()still returns the old error while the status claims'idle',- every subsequent
reload()returnsfalse(the'idle'guard), so a "Retry" button is
permanently dead.
The cause is in ResourceImpl.reload() (packages/core/src/resource/resource.ts:407):
this.extRequest.update(({request, reload}) => ({request, reload: reload + 1}));
extRequest is a union: after a params error its value is {error, reload}, with no request
field. Destructuring request yields undefined and the rebuilt object drops error, so the state
computation maps request === undefined to 'idle' (resource.ts:320) while reusing the previous —
error — stream (resource.ts:321), which is why error() keeps reporting the stale error.
Expected behavior: reload() should return false and leave the error state untouched when the
error came from params (only a params change can recover it), or alternatively preserve the error
state instead of fabricating 'idle'. Returning true without loading, and reporting 'idle'
while error() is set, are both incoherent.
Minimal reproduction (TestBed spec)
import {ApplicationRef, Injector, resource, signal} from '@angular/core';
import {TestBed} from '@angular/core/testing';
it('reload() while params is in error', async () => {
const s = signal<string | Error>(new Error('params failed'));
let loads = 0;
const res = resource({
params: () => {
const v = s();
if (v instanceof Error) throw v;
return v;
},
loader: async ({params}) => {
loads++;
return params;
},
injector: TestBed.inject(Injector),
});
await TestBed.inject(ApplicationRef).whenStable();
expect(res.status()).toBe('error'); // ✓
const result = res.reload();
await TestBed.inject(ApplicationRef).whenStable();
console.log(result); // true — claims a reload happened
console.log(res.status()); // 'idle' — was 'error'
console.log(res.error()); // Error: params failed — still set while 'idle'
console.log(loads); // 0 — loader never ran
console.log(res.reload()); // false — retry permanently dead
});
Observed on main (c27695f278, 22.3.0-next.2); the relevant code is unchanged in 22.x stable.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run ng version)
Anything else?
No response
- Lenguaje dominante
- TypeScript
- Estrellas
- 101k
- Forks
- 30.3k
- Merge medio
- 2 d 5 h
- PR fusionados (30 d)
- 378
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de angular/angular
-
Event replay: early event contract listeners on <body> are never removed after hydrationPosiblemente ocupada @arturovt la tomó hace 5 días. Abiertoarea: core
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
area: compiler
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
angular/angular#71511 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
resource: destroying a resource calls AbortController.abort() without a reason, creating an AbortError with a stack trace each timePosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoarea: core cross-cutting: resource
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
angular/angular#71422 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
feat(router/testing): Add navigate method to RouterTestingHarnessPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoarea: core feature gemini-triaged needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
angular/angular#71210 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Signal Forms: `validateStandardSchema` throws a TypeError for an issue whose path runs through a key the model lacksPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoarea: forms gemini-triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
Todos los issues de angular/angular
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Merit-Systems/x402scan#1312 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Native Web
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
digitalfabrik/integreat-app#4517 ·
Los mantenedores suelen responder en 2 días
-
TLS guide repeats certs/ in the certificate directoryPosiblemente ocupada @maheshrijal la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
prometheus/docs#3156 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
medusajs/dtc-starter#90 ·
Los mantenedores suelen responder en 1 día