Skip to content

fix(core): prevent resource.reload() from switching to idle on params error - #72209

Draft
JeanMeche wants to merge 1 commit into
angular:mainfrom
JeanMeche:fix/resource-reload-params-error
Draft

JeanMeche wants to merge 1 commit into
angular:mainfrom
JeanMeche:fix/resource-reload-params-error

Conversation

@JeanMeche

Copy link
Copy Markdown
Member

Fixes #71585.

Summary

  • Guard ResourceImpl.reload() to return false when extRequest.error !== undefined or extRequest.request === undefined, preserving the existing state instead of dropping error and transitioning to 'idle'.
  • Guard stream reuse in ResourceImpl's state computation with request !== undefined so transitioning from a params error to undefined ('idle') does not carry over the stale error stream (which caused hasValue() and snapshot() to throw ResourceValueError).
  • Add unit tests covering chained resource dependency errors, direct params errors, params error -> undefined transitions, and reload() after set() when params is undefined or in error.

… error

When a resource's `params` function throws (for example via `chain()` on an errored upstream resource), `extRequest` holds `{error, reload}` with no `request` property. Calling `reload()` previously destructured `request` as `undefined` and dropped `error`, transitioning the resource to `'idle'` while reusing the previous error stream because `undefined === undefined`. This left `status()` as `'idle'` while `error()` still reported the error, and caused `hasValue()` and `snapshot()` to throw `ResourceValueError`.

Guard `reload()` to return `false` when `extRequest` has an `error` or `request === undefined`, and avoid reusing `previous.value.stream` when transitioning to `'idle'` (`request === undefined`).

Closes angular#71585
@angular-robot angular-robot Bot added the area: core Issues related to the framework runtime label Nov 25, 2026
@ngbot ngbot Bot added this to the Backlog milestone Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Issues related to the framework runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

resource.reload() while params is in error switches the resource to 'idle' instead of retrying

1 participant