Skip to content

fix(forms): safely chain debounced async validation resources - #71414

Open
benjavicente wants to merge 1 commit into
angular:mainfrom
benjavicente:fix/safe-chain-resources-async-validation
Open

benjavicente wants to merge 1 commit into
angular:mainfrom
benjavicente:fix/safe-chain-resources-async-validation

Conversation

@benjavicente

@benjavicente benjavicente commented Oct 17, 2026 •

Copy link
Copy Markdown

PR Checklist

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

In signal forms, validateAsync with debounce configured passes a params signal that can throw the internal ResourceParamsStatus.LOADING. Factories that consume that signal in an effect or use resourceFromSnapshots can fail outside the resource() params handler.

The 傻chain function seems only used in that way in signal forms (傻chain( has only 1 result in the codebase), and the docs mention that chain is to be used on the params function, giving the consumer the option to chain resources, while the validateAsync function hides that and can lead to unexpected errors when the param function throws in an unexpected context. That creates a problem for libraries that can return the Resource interface but don't use the Resource API, since it's the Resource API param's function that catches the issue, not the Interface that libraries can implement to adapt into Angular libraries.

Issue Number: #70884

What is the new behavior?

Pass a safe debounced params signal to the factory, retaining the previous value during debounce, and compose the debounce resource and factory resource safely, without 傻chain. The safe chain forwards reloads to preserves reloadValidation() functionality.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

In the future, a resource type that declares the Resource & { reload: () => boolean } could be used as a union to better declare the usage of the reload method, see #69443 (alternatives considered for validateAsync interface) and #71299 (Router's nonBlocking utility type).

Pass debounced params to async validator factories without exposing resource
status sentinels. Compose snapshots separately to preserve pending and error
states, and delegate reloads after debounce settles.

Add regression coverage for effects, custom snapshots, params error recovery,
and reloadValidation.

Fixes angular#70884
@pullapprove
pullapprove Bot requested a review from atscott October 17, 2026 23:20
@ngbot ngbot Bot added this to the Backlog milestone Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant