Skip to content

Resource: value.set() fails after resource goes in error state #62241

Closed

Description

@twatzl

Which @angular/* package(s) are the source of the bug?

common, core

Is this a regression?

Yes

Description

Using a resource as described in
https://angular.dev/guide/signals/resource#reactive-data-fetching-with-httpresource

Expectation
It is possible to overwrite the resource value manually.

Actual Behavior
After the resource entered error state value.set() fails. It is also not possible to manually clear the error state unless doing a reload.

Example:
see the stackblitz attached

How to reproduce

  1. wait for the stackblitz to load
  2. now there are two resources, one simulating a successful api call, another one a failing api call
  3. now click the button to set the values
  4. value of resource A is now set and state changed to local, but value of resource B is not set, instead there is an exception claiming Resource is currently in an error state

Notes

I am not sure if this is an actual issue or just a documentation issue, but the fact that there is a "local" state and it works before the resource enters error state indicates to me that it is indeed an intended use case for resources to be overridden manually, but there is just documentation or functionality lacking to clear the error state.

The same code worked with angular 19.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-fmd8ihf4?file=src%2Fmain.ts

Please provide the exception or error you saw

[email protected]:26 ERROR ResourceValueError: Resource is currently in an error state (see Error.cause for details): oh no!
    at ResourceImpl.computed.equal.equal [as computation] (resource-BPCh38bN.mjs:383:27)
    at Object.producerRecomputeValue (signal-ePSl6jXn.mjs:411:33)
    at producerUpdateValueVersion (signal-ePSl6jXn.mjs:139:10)
    at ResourceImpl.computed2 [as value] (signal-ePSl6jXn.mjs:351:9)
    at App_Template (main.ts:26:5)
    at executeTemplate (debug_node-Dn-GvQJo.mjs:7142:9)
    at refreshView (debug_node-Dn-GvQJo.mjs:8887:13)
    at detectChangesInView (debug_node-Dn-GvQJo.mjs:9107:9)
    at detectChangesInViewIfAttached (debug_node-Dn-GvQJo.mjs:9067:5)
    at detectChangesInComponent (debug_node-Dn-GvQJo.mjs:9055:5)Caused by: Error: oh no!
    at main.ts:7:11
    at new ZoneAwarePromise (zone.js:2702:25)
    at main.ts:6:10
    at Generator.next (<anonymous>)
    at main.js:41:61
    at new ZoneAwarePromise (zone.js:2702:25)
    at __async (main.js:25:10)
    at mockApiCallFailing (main.ts:5:34)
    at Object.loader (main.ts:35:42)
    at resource-BPCh38bN.mjs:576:50

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 20.0.0
Node: 20.19.1
Package Manager: npm 10.8.2
OS: linux x64

Angular: 20.0.0
... animations, build, cli, common, compiler, compiler-cli, core
... forms, platform-browser, router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.2000.0
@angular-devkit/core         20.0.0
@angular-devkit/schematics   20.0.0
@schematics/angular          20.0.0
rxjs                         7.8.2
typescript                   5.8.2
zone.js                      0.15.0

Anything else?

No response

Activity

  1. added
    area: core
    cross-cutting: resource
    on Jun 24, 2025
  2. modified the milestone: needsTriage on Jun 24, 2025
  3. added a commit that references this issue on Jun 25, 2025
    7832966
  4. added a commit that references this issue on Jun 25, 2025
    a2e6f31
  5. added a commit that references this issue on Jun 25, 2025
    36a1931
  6. angular-automatic-lock-bot commented on Jul 26, 2025

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  7. locked and limited conversation to collaborators on Jul 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corecross-cutting: resource

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions