fix(angular-query): handle ResourceParamsStatus sentinel errors in optionsFn and toResource - #11724
Open
lx3133584 wants to merge 1 commit into
Conversation
…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>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: TanStack/query/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #11586.
When
injectQueryortoResource(injectQuery(...))is integrated with Angular Signal FormsvalidateAsync(or when query options read an Angular Resource parameter during debounce/pending load), Angular can throw a sentinelResourceParamsStatus.LOADINGorResourceParamsStatus.IDLEfrom the reactive parameter signal.Previously,
defaultedOptionsSignalininjectBaseQueryexecutedoptionsFn()directly insidecomputed(). WhenoptionsFn()threw theResourceParamsStatussentinel error, the exception leaked into the outereffect(), triggering an unhandled global console error:Changes
ResourceParamsStatusininjectBaseQuery:ResourceParamsStatus.LOADING,ResourceParamsStatus.IDLE, andResourceDependencyErrorwithout throwing out of the computed context.enabled: false) using previous options or fallback options. When the parameter signal settles, the computed signal automatically re-evaluates and resumes normal execution.toResource:toResource, when parameter loading/idle status is active, map the resource status to'loading'(or'idle') so that consumer integrations likevalidateAsynccorrectly report theirpendingvalidation state instead of crashing.upstream-issues.test.tsverifying thatResourceParamsStatus.LOADINGandIDLEdo not leak unhandled errors and settle cleanly once parameters resolve.🤖 Generated with Claude Code