Skip to content

fix(angular-query): handle ResourceParamsStatus sentinel errors in optionsFn and toResource - #11724

Open
lx3133584 wants to merge 1 commit into
TanStack:angular-adapter-prefrom
lx3133584:fix/angular-query-resource-params-sentinel
Open

lx3133584 wants to merge 1 commit into
TanStack:angular-adapter-prefrom
lx3133584:fix/angular-query-resource-params-sentinel

Conversation

@lx3133584

Copy link
Copy Markdown

Summary

Fixes #11586.

When injectQuery or toResource(injectQuery(...)) is integrated with Angular Signal Forms validateAsync (or when query options read an Angular Resource parameter during debounce/pending load), Angular can throw a sentinel ResourceParamsStatus.LOADING or ResourceParamsStatus.IDLE from the reactive parameter signal.

Previously, defaultedOptionsSignal in injectBaseQuery executed optionsFn() directly inside computed(). When optionsFn() threw the ResourceParamsStatus sentinel error, the exception leaked into the outer effect(), triggering an unhandled global console error:

ERROR ResourceParamsStatus: LOADING

Changes

  1. Catch ResourceParamsStatus in injectBaseQuery:
    • Safely handle ResourceParamsStatus.LOADING, ResourceParamsStatus.IDLE, and ResourceDependencyError without throwing out of the computed context.
    • When parameter status is not ready, suspend query execution gracefully (enabled: false) using previous options or fallback options. When the parameter signal settles, the computed signal automatically re-evaluates and resumes normal execution.
  2. Reflect parameter status in toResource:
    • In toResource, when parameter loading/idle status is active, map the resource status to 'loading' (or 'idle') so that consumer integrations like validateAsync correctly report their pending validation state instead of crashing.
  3. Tests:

🤖 Generated with Claude Code

…tionsFn and toResource

When query options read an Angular Resource or debounced signal parameter (such as in Signal Forms `validateAsync`), Angular can throw a sentinel `ResourceParamsStatus.LOADING` or `ResourceParamsStatus.IDLE` while the parameter is pending.

Safely catch `ResourceParamsStatus` in `injectBaseQuery` so that the query suspends with `enabled: false` instead of leaking an unhandled effect error to the global console. Reflect the loading/idle state in `toResource` so that form async validators correctly track pending status without error.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: TanStack/query/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: b972f851-3eb1-4c66-ad39-7958bce4e10e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant