fix(tanstack-query): correct error type on streamed and live options#892
fix(tanstack-query): correct error type on streamed and live options#892
Conversation
Uses DefaultError instead of TError because TError only applies to the initial request. Streaming errors are not validated, so type safety cannot be guaranteed for error types.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughError typing for streaming/live utilities was standardized to DefaultError/Error across React, Solid, Svelte, Vue, and TanStack Query packages. Public signatures for experimental streamed/live helpers now use DefaultError. Type-test expectations were updated to assert Error instead of mapped/UtilsError types. Documentation remarks were added about streaming errors not being validated. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Summary of Changes
Hello @unnoq, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request addresses a critical type safety concern within the experimental streamed and live query options across various Tanstack Query integrations. The primary goal is to ensure robust error handling by correctly typing errors that occur during streaming operations. Previously, a generic TError type was used, which is only suitable for initial request errors. Since streaming errors lack the same validation guarantees, this change standardizes their type to DefaultError (or Error in tests), providing a more accurate and reliable type definition for these scenarios. This refactor enhances the overall stability and predictability of error handling in these advanced query features.
Highlights
- Standardized Error Handling: The error type for experimental streamed and live query options has been standardized to
DefaultError(orErrorin test contexts) across all Tanstack Query integrations. - Improved Type Safety: The previous
TErrortype was deemed inappropriate for streaming errors because these errors are not validated and thus cannot guarantee specific type safety, leading to potential type mismatches. - Widespread Type Definition Updates: Relevant type definition test files (
.test-d.ts) and core utility files (procedure-utils.ts) inreact-query,solid-query,svelte-query,tanstack-query, andvue-querypackages have been updated to reflect this change.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request correctly addresses an issue with error typing for streamed and live options in TanStack Query integrations. By switching from TError to DefaultError (Error), the changes ensure type safety for streaming errors, which are not validated against the initial request's error type. The modifications are consistently applied across all relevant packages (React, Solid, Svelte, Vue, Angular), and the added @remarks in the JSDoc comments provide helpful context. I've found one minor issue in a test file, which appears to be a pre-existing copy-paste error. Overall, this is a well-executed fix.
| expectTypeOf(queries.value[0].error).toEqualTypeOf<null | ErrorFromErrorMap<typeof baseErrorMap>>() | ||
| expectTypeOf(queries.value[0].error).toEqualTypeOf<null | ErrorFromErrorMap<typeof baseErrorMap>>() | ||
| expectTypeOf(queries.value[0].error).toEqualTypeOf<null | Error>() | ||
| expectTypeOf(queries.value[0].error).toEqualTypeOf<null | Error>() |
There was a problem hiding this comment.
This line appears to be a duplicate of the one above, as it checks queries.value[0].error twice. I believe the intention was to check queries.value[1].error here.
| expectTypeOf(queries.value[0].error).toEqualTypeOf<null | Error>() | |
| expectTypeOf(queries.value[1].error).toEqualTypeOf<null | Error>() |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull Request Overview
This pull request corrects error type handling for streamed and live query options in TanStack Query integrations. Instead of using the generic TError type parameter, these methods now use DefaultError to ensure type safety.
- Changes error types from
TErrortoDefaultErrorfor streaming operations - Updates type definitions and test expectations across multiple framework packages
- Adds documentation remarks explaining the rationale for using
DefaultError
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/tanstack-query/src/procedure-utils.ts | Updates core procedure utility types to use DefaultError for streaming operations |
| packages/vue-query/src/procedure-utils.ts | Updates Vue Query integration to use DefaultError for streamed options |
| packages/svelte-query/src/procedure-utils.ts | Updates Svelte Query integration to use DefaultError for streamed options |
| packages/solid-query/src/procedure-utils.ts | Updates Solid Query integration to use DefaultError for streamed options |
| packages/react-query/src/procedure-utils.ts | Updates React Query integration to use DefaultError for streamed options |
| Multiple test files | Updates type expectations in tests to use Error instead of custom error types |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
More templates
@orpc/arktype
@orpc/client
@orpc/contract
@orpc/experimental-durable-event-iterator
@orpc/hey-api
@orpc/interop
@orpc/json-schema
@orpc/nest
@orpc/openapi
@orpc/openapi-client
@orpc/otel
@orpc/react
@orpc/react-query
@orpc/server
@orpc/shared
@orpc/solid-query
@orpc/standard-server
@orpc/standard-server-aws-lambda
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/standard-server-peer
@orpc/svelte-query
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (12)
packages/tanstack-query/src/procedure-utils.test-d.ts (1)
426-426: Update streamed/live test expectations to use Error instead of UtilsErrorSince
getQueryStatenow widens the error type toError, the corresponding streaming/live option tests should align with this change. Please update the generic onQueryObserverOptionsin these two specs:• packages/tanstack-query/src/procedure-utils.test-d.ts
- Line 267:
- expectTypeOf(streamUtils.experimental_streamedOptions()) - .toExtend<QueryObserverOptions<UtilsOutput, UtilsError>>() + expectTypeOf(streamUtils.experimental_streamedOptions()) + .toExtend<QueryObserverOptions<UtilsOutput, Error>>()- Line 396:
- expectTypeOf(streamUtils.experimental_liveOptions()) - .toExtend<QueryObserverOptions<UtilsOutput[number], UtilsError>>() + expectTypeOf(streamUtils.experimental_liveOptions()) + .toExtend<QueryObserverOptions<UtilsOutput[number], Error>>()This will keep the tests consistent with the updated error contract and match the patterns used in React/Vue/Solid.
packages/react-query/tests/e2e.test-d.ts (1)
142-148: Optional: Add a negative assertion to guard against accidental re-narrowing of streamed errors.A tiny compile-time check helps ensure we never rely on domain-specific error shapes on streaming paths.
Apply this diff near the retry callback to assert that Error doesn’t expose a code field:
retry(failureCount, error) { - expectTypeOf(error).toEqualTypeOf<Error>() + expectTypeOf(error).toEqualTypeOf<Error>() + // @ts-expect-error --- streaming errors are unvalidated; 'code' is not guaranteed on Error + error.codepackages/svelte-query/src/procedure-utils.test-d.ts (1)
186-193: Optional: Lock in the “no code” guarantee for streamed errors.Add a negative assertion so future changes don’t accidentally reintroduce structured error typing in streaming:
throwOnError(error) { - expectTypeOf(error).toEqualTypeOf<Error>() + expectTypeOf(error).toEqualTypeOf<Error>() + // @ts-expect-error --- streamed errors are generic Error; no 'code' available + error.code return false },packages/svelte-query/tests/e2e.test-d.ts (1)
118-124: Optional: Add a compile-time guard against using domain fields on streamed errors.Keeps the intent future-proof.
retry(failureCount, error) { - expectTypeOf(error).toEqualTypeOf<Error>() + expectTypeOf(error).toEqualTypeOf<Error>() + // @ts-expect-error --- no typed 'code' on generic Error for streamed paths + error.code return false },packages/react-query/src/procedure-utils.test-d.ts (1)
218-224: Optional: Assert that streamed errors cannot be narrowed to domain error shapes.This helps catch accidental leakage of E into streamed helpers.
throwOnError(error) { - expectTypeOf(error).toEqualTypeOf<Error>() + expectTypeOf(error).toEqualTypeOf<Error>() + // @ts-expect-error --- streamed errors are generic Error; 'code' is not part of the type + error.code return false },packages/tanstack-query/src/procedure-utils.solid.test-d.ts (1)
98-105: Optional: Add a negative assertion to prevent accidental structured error usage on streamed/live.const query = useQuery(() => streamUtils.experimental_streamedOptions({ throwOnError(error) { - expectTypeOf(error).toEqualTypeOf<Error>() + expectTypeOf(error).toEqualTypeOf<Error>() + // @ts-expect-error --- streamed errors are generic Error; 'code' must not be relied upon + error.code return false }, }))packages/react-query/src/procedure-utils.ts (1)
39-45: JSDoc remark is helpful; minor typo in “streamedQuery” referenceThe remark clarifies why DefaultError is used for streaming. There’s a small typo: “steamedQuery” -> “streamedQuery”.
Apply this diff to fix the typo:
- * Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery) + * Built on top of [streamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)packages/vue-query/src/procedure-utils.test-d.ts (1)
261-263: Duplicate assertions on queries.value[0].errorThere are two identical expectTypeOf assertions on queries.value[0].error. Consider keeping a single assertion to reduce noise.
Apply this diff to remove the duplicate:
- expectTypeOf(queries.value[0].error).toEqualTypeOf<null | Error>() - expectTypeOf(queries.value[0].error).toEqualTypeOf<null | Error>() + expectTypeOf(queries.value[0].error).toEqualTypeOf<null | Error>()packages/svelte-query/src/procedure-utils.ts (1)
29-33: Nit: “steamedQuery” -> “streamedQuery” in the docMinor typo in the JSDoc reference.
Apply this diff:
- * Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery) + * Built on top of [streamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)packages/solid-query/src/procedure-utils.ts (1)
29-34: Nit: “steamedQuery” -> “streamedQuery” in the docSame minor typo as in Svelte Query.
Apply this diff:
- * Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery) + * Built on top of [streamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)packages/vue-query/src/procedure-utils.ts (1)
31-36: Nit: “steamedQuery” -> “streamedQuery” in the docMinor typo in the JSDoc reference.
Apply this diff:
- * Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery) + * Built on top of [streamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)packages/tanstack-query/src/procedure-utils.svelte.test-d.ts (1)
99-106: Optional: Add retryDelay type inference coverage for streaming/liveSince QueryOptionsBase includes retryDelay?: (count: number, error: TError) => number, it’s useful to assert the error parameter infers as Error for streamed/live utilities.
You can extend an existing test like this:
const q = createQuery(streamUtils.experimental_streamedOptions({ retryDelay(count, error) { expectTypeOf(count).toEqualTypeOf<number>() expectTypeOf(error).toEqualTypeOf<Error>() return 0 }, }))And similarly for experimental_liveOptions.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (20)
packages/react-query/src/procedure-utils.test-d.ts(4 hunks)packages/react-query/src/procedure-utils.ts(2 hunks)packages/react-query/tests/e2e.test-d.ts(6 hunks)packages/solid-query/src/procedure-utils.test-d.ts(3 hunks)packages/solid-query/src/procedure-utils.ts(2 hunks)packages/solid-query/tests/e2e.test-d.ts(3 hunks)packages/svelte-query/src/procedure-utils.test-d.ts(3 hunks)packages/svelte-query/src/procedure-utils.ts(2 hunks)packages/svelte-query/tests/e2e.test-d.ts(3 hunks)packages/tanstack-query/src/procedure-utils.angular.test-d.ts(6 hunks)packages/tanstack-query/src/procedure-utils.react.test-d.ts(10 hunks)packages/tanstack-query/src/procedure-utils.solid.test-d.ts(6 hunks)packages/tanstack-query/src/procedure-utils.svelte.test-d.ts(6 hunks)packages/tanstack-query/src/procedure-utils.test-d.ts(4 hunks)packages/tanstack-query/src/procedure-utils.ts(2 hunks)packages/tanstack-query/src/procedure-utils.vue.test-d.ts(6 hunks)packages/tanstack-query/tests/e2e.test-d.ts(6 hunks)packages/vue-query/src/procedure-utils.test-d.ts(2 hunks)packages/vue-query/src/procedure-utils.ts(2 hunks)packages/vue-query/tests/e2e.test-d.ts(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (5)
packages/solid-query/src/procedure-utils.ts (2)
packages/solid-query/src/types.ts (3)
experimental_InferStreamedOutput(28-28)experimental_StreamedOptionsIn(30-32)experimental_StreamedOptionsBase(34-35)packages/shared/src/args.ts (1)
MaybeOptionalOptions(1-3)
packages/react-query/src/procedure-utils.ts (5)
packages/react-query/src/types.ts (1)
experimental_InferStreamedOutput(20-20)packages/solid-query/src/types.ts (1)
experimental_InferStreamedOutput(28-28)packages/svelte-query/src/types.ts (1)
experimental_InferStreamedOutput(28-28)packages/vue-query/src/types.ts (1)
experimental_InferStreamedOutput(41-41)packages/shared/src/args.ts (1)
MaybeOptionalOptions(1-3)
packages/vue-query/src/procedure-utils.ts (4)
packages/react-query/src/types.ts (3)
experimental_InferStreamedOutput(20-20)experimental_StreamedOptionsIn(22-24)experimental_StreamedOptionsBase(26-27)packages/vue-query/src/types.ts (3)
experimental_InferStreamedOutput(41-41)experimental_StreamedOptionsIn(43-45)experimental_StreamedOptionsBase(47-48)packages/shared/src/args.ts (1)
MaybeOptionalOptions(1-3)packages/tanstack-query/src/types.ts (2)
experimental_StreamedOptionsIn(60-62)experimental_StreamedOptionsBase(64-65)
packages/tanstack-query/tests/e2e.test-d.ts (1)
packages/tanstack-query/tests/shared.tsx (1)
streamedOrpc(6-6)
packages/tanstack-query/src/procedure-utils.ts (2)
packages/shared/src/args.ts (1)
MaybeOptionalOptions(1-3)packages/tanstack-query/src/types.ts (6)
experimental_StreamedKeyOptions(56-58)experimental_StreamedQueryOutput(15-15)QueryKeyOptions(39-41)experimental_LiveQueryOutput(16-16)QueryOptionsIn(43-46)QueryOptionsBase(48-54)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: publish-commit
- GitHub Check: lint
- GitHub Check: test
🔇 Additional comments (61)
packages/vue-query/tests/e2e.test-d.ts (4)
113-117: Streaming retry now asserts Error — aligned with DefaultError intentSwitching the retry error type to Error matches the PR goal that streamed errors aren’t validated and should use DefaultError (which resolves to Error). Looks good.
120-122: Error branch asserts Error — good simplificationChecking status + presence of error and asserting Error removes incorrect map-based narrowing for streamed paths. This is appropriate.
148-152: useQueries streamed retry error typed as Error — consistentThe throwOnError/Retry expectation generalized to Error is consistent with the streaming error policy.
160-162: useQueries streamed error is Error — consistentAsserting Error on the error branch aligns with DefaultError for streaming.
packages/tanstack-query/src/procedure-utils.test-d.ts (3)
217-221: .streamedKey getQueryState error widened to Error — consistentUpdating state?.error to Error | null | undefined for streamedKey matches the DefaultError approach. Good change.
294-298: .streamedOptions getQueryState error widened to Error — consistentThis matches the intent for streaming errors to be unvalidated (DefaultError). Good.
346-350: .liveKey getQueryState error widened to Error — consistentAligns with DefaultError for live paths. Looks good.
packages/tanstack-query/src/procedure-utils.react.test-d.ts (8)
146-159: Streamed useQuery: error surfaces generalized to Error — correct
- query.error: Error | null
- throwOnError parameter: Error
Matches DefaultError usage for streaming. Good.
172-199: Streamed useSuspenseQuery: error typed as Error — consistentBoth query.error and throwOnError are generalized to Error. Alignment looks correct.
215-222: Streamed useQueries: error tuples now null | Error — consistentAll entries updated to null | Error. Good coverage.
242-245: Streamed useSuspenseQueries: error tuples now null | Error — consistentMatches the policy for streaming error typing.
259-273: Live useQuery: error and throwOnError now Error — correctGeneralization to Error aligns with live error semantics.
286-312: Live useSuspenseQuery: error typed as Error — consistentAll assertions updated to Error; good alignment.
333-336: Live useQueries: errors now null | Error — consistentConsistent with the rest of the streaming/live updates.
356-359: Live useSuspenseQueries: errors now null | Error — consistentLooks good.
packages/tanstack-query/src/procedure-utils.vue.test-d.ts (6)
100-114: Streamed useQuery (Vue): error surfaces generalized to Error — correct
- query.error.value is Error | null
- throwOnError parameter is Error
This matches the DefaultError direction.
122-125: Streamed useQuery with initialData: error is Error — consistentEven with initialData + select, error typing remains Error | null. Good.
147-149: Streamed useQueries (Vue): items’ errors now null | Error — consistentUpdated across all query entries. Good.
167-180: Live useQuery (Vue): error and throwOnError now Error — correctGeneralization to Error aligns with the live error contract.
188-191: Live useQuery with initialData: error is Error — consistentRemains Error | null with initialData + select. Good.
213-215: Live useQueries (Vue): errors now null | Error — consistentMatches other frameworks.
packages/solid-query/src/procedure-utils.test-d.ts (3)
185-195: Streamed useQuery (Solid): throwOnError and error now Error — correct
- throwOnError(error): Error
- query.error: Error | null
Consistent with DefaultError for streaming.
197-205: Streamed useQuery with initialData: error is Error — consistentGood alignment.
224-226: Streamed useQueries (Solid): errors now null | Error — consistentMatches the broader update across frameworks.
packages/react-query/tests/e2e.test-d.ts (1)
144-146: Standardizing streamed error typing to Error looks correct and consistent.These updates align streaming retry/error paths to Error, matching the PR objective that streamed/live errors aren’t validated. Assertions remain precise and non-streaming paths still use domain errors where applicable.
Also applies to: 150-152, 178-181, 184-186, 213-216, 224-226, 248-251, 259-261
packages/svelte-query/src/procedure-utils.test-d.ts (1)
189-192: Streamed query error surfaces generalized to Error: OK.
- throwOnError(error) now expects Error.
- query.error and queries[i].error now typed as Error | null (or null | Error).
This aligns with the rationale that streamed errors aren’t validated.Also applies to: 194-196, 204-206, 225-227
packages/svelte-query/tests/e2e.test-d.ts (1)
121-124: Good: Streamed paths now assert Error for retry/error branches.Consistent with the shift to unvalidated streaming errors. Non-streaming paths keep the richer domain error checks.
Also applies to: 129-131, 160-163, 173-175
packages/react-query/src/procedure-utils.test-d.ts (2)
221-224: React Query procedure utils (streamed) switched to Error: LGTM.
- throwOnError(error) → Error
- query.error/queries[].error → Error | null (or null | Error)
Matches the PR’s “DefaultError on streaming” intent while keeping non-streaming with mapped errors.Also applies to: 227-229, 237-239, 257-259, 277-279
1-512: All streamed/live helpers reference DefaultError; no tests expect domain Error.
Repo-wide search confirms every framework adapter’sexperimental_streamedOptions/experimental_liveOptionsusesDefaultError, and no.test-d.tsfiles assert on the oldErrortype. No further action required.packages/tanstack-query/src/procedure-utils.solid.test-d.ts (1)
95-97: Solid (tanstack-query) tests: streamed/live error typing unified to Error: well done.
- useQuery/useQueries for streamed and live now surface Error | null and throwOnError(error: Error).
- Non-streaming sections still use mapped UtilsError.
This mirrors the cross-framework direction in the PR.Also applies to: 101-107, 115-117, 138-141, 157-169, 178-179, 200-203
packages/solid-query/tests/e2e.test-d.ts (4)
115-119: Use Error for streamed retry callback is correctSwitching the streamed retry callback error typing to Error aligns with DefaultError usage for streaming. Looks good.
122-124: Streamed error branch now expects Error — LGTMAsserting query.error is Error in the streamed path matches the new DefaultError typing strategy.
152-156: useQueries streamed retry callback now typed as Error — LGTMThe retry callback error parameter typed as Error is consistent with non-validated streaming errors.
164-166: Streamed useQueries error type normalized to Error — LGTMChecking queries[0].error as Error in the streamed scenario is correct with DefaultError semantics.
packages/react-query/src/procedure-utils.ts (1)
3-3: Importing DefaultError is necessary for streamed optionsPulling DefaultError from @tanstack/react-query is required for the new streamed typing. Good change.
packages/tanstack-query/tests/e2e.test-d.ts (6)
187-187: .streamedKey error typed as Error | null | undefined — LGTMThe query state error shape matches DefaultError in TanStack Query.
194-197: Retry error in streamed options standardized to ErrorGood alignment with DefaultError on the streamed path.
201-203: Streamed useQuery error branch now Error — LGTMThis matches the new default streaming error typing.
229-237: Suspense streamed retry/error typing normalized to ErrorBoth the retry callback and the status 'error' branch typing look correct.
264-277: useQueries streamed typing uses Error — LGTMUniform Error typing for retry callback and error branch is consistent and correct.
299-312: useSuspenseQueries streamed typing uses Error — LGTMConsistent with the broader move to DefaultError for streamed paths.
packages/vue-query/src/procedure-utils.test-d.ts (4)
221-223: throwOnError(error) now typed as Error for streamed options — LGTMCorrectly reflects DefaultError on the streaming path.
227-228: useQuery streamed error.value typed as Error | null — LGTMMatches the normalized streaming error type.
235-236: throwOnError(error) remains Error with initialData — LGTMConsistent with streamed error typing.
241-242: useQuery streamed error.value typed as Error | null (with initialData) — LGTMpackages/tanstack-query/src/procedure-utils.angular.test-d.ts (5)
100-112: Streamed injectQuery now expects Error — LGTMMoving error()/throwOnError(error) to Error for streamed options is consistent with DefaultError semantics.
145-148: injectQueries streamed errors typed as Error — LGTMAll queries’ error types normalized to Error in streamed context; looks good.
164-176: liveOptions injectQuery errors typed as Error — LGTMError typing for liveOptions follows the same DefaultError approach; good consistency.
185-186: liveOptions injectQuery with initialData uses Error — LGTM
209-212: liveOptions injectQueries errors typed as Error — LGTMNormalization to Error across the array of queries is correct.
packages/svelte-query/src/procedure-utils.ts (1)
37-39: LGTM: Streamed error typing switched to DefaultErrorUsing DefaultError in experimental_StreamedOptionsIn and the return base aligns with the rationale that streaming errors aren’t validated. This is consistent with the broader PR direction.
packages/solid-query/src/procedure-utils.ts (2)
3-3: Verify DefaultError availability in the targeted Solid Query versionImport is correct, but ensure your peer/dev deps target a version of @tanstack/solid-query that exposes DefaultError.
Use the same script as above; it checks all package.json files and prints @TanStack deps found.
37-39: LGTM: Streamed error typing switched to DefaultErrorThe type change to DefaultError in both input and return types is consistent and matches the PR’s intent.
packages/tanstack-query/src/procedure-utils.ts (3)
61-82: LGTM: streamedKey/streamedOptions now typed with DefaultError
- DataTag keyed types switched to DefaultError for streamedKey.
- Streamed options input and return base types now use DefaultError.
- The documentation remark captures the reasoning clearly.
This brings the core utility in line with framework adapters and the tests.
87-108: LGTM: liveKey/liveOptions now typed with DefaultErrorMatching the streamed path, liveKey and liveOptions now consistently use DefaultError, and the docs reflect the non-validated nature of streaming/live errors. Looks good.
3-3: Version alignment for DefaultError verified
- In packages/tanstack-query/package.json,
@tanstack/query-coreis declared as:
- peerDependency:
>=5.80.2- devDependency:
^5.85.3These bounds ensure that
DefaultErroris available for both consumers and local development. No further changes are needed.packages/vue-query/src/procedure-utils.ts (2)
3-3: Verify DefaultError availability in the targeted Vue Query versionThe DefaultError import is correct. Please ensure your peer/dev deps for @tanstack/vue-query are at a version exporting DefaultError to avoid TS issues for consumers.
Use the earlier script; it reports @tanstack/vue-query versions across the repo.
39-41: LGTM: Streamed error typing switched to DefaultErrorInput and return types correctly updated to DefaultError. This matches the rest of the PR and the accompanying tests.
packages/tanstack-query/src/procedure-utils.svelte.test-d.ts (3)
96-108: LGTM: Streamed options assert Error for error surfacesSwitching expected error types in streamedOptions to Error matches the new DefaultError typing and the “errors not validated” guidance.
116-142: LGTM: createQueries for streamedOptions expects per-query Error | nullThese expectations align with the new DefaultError-typed DataTag and QueryOptionsBase error surfaces.
156-170: LGTM: Live options assert Error for error surfacesThe liveOptions tests mirror the streamedOptions changes and look correct.
| ...rest: MaybeOptionalOptions< | ||
| U & StreamedOptionsIn<TClientContext, TInput, experimental_InferStreamedOutput<TOutput>, TError, USelectData> | ||
| U & StreamedOptionsIn<TClientContext, TInput, experimental_InferStreamedOutput<TOutput>, DefaultError, USelectData> | ||
| > | ||
| ): NoInfer<U & Omit<StreamedOptionsBase<experimental_InferStreamedOutput<TOutput>, TError>, keyof U>> | ||
| ): NoInfer<U & Omit<StreamedOptionsBase<experimental_InferStreamedOutput<TOutput>, DefaultError>, keyof U>> | ||
|
|
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Type parameters updated to DefaultError — correct and consistent
Using DefaultError in StreamedOptionsIn and StreamedOptionsBase matches TanStack’s default streaming error shape and the PR’s intent.
To ensure there are no remaining streamed/live utilities typed with TError, you can run:
🏁 Script executed:
#!/bin/bash
# Verify streamed/live option typings consistently use DefaultError instead of TError
set -euo pipefail
echo "Searching for StreamedOptionsIn with TError..."
rg -nP 'experimental_?StreamedOptionsIn<[^>]*,\s*TError' -S || echo "OK: No StreamedOptionsIn<> with TError found."
echo "Searching for StreamedOptionsBase with TError..."
rg -nP 'experimental_?StreamedOptionsBase<[^>]*,\s*TError' -S || echo "OK: No StreamedOptionsBase<> with TError found."
echo "Searching for experimental_streamedOptions signatures using TError..."
rg -nP 'experimental_streamedOptions<[^>]*TError' -S || echo "OK: No experimental_streamedOptions<> with TError found."
echo "Searching for experimental_liveOptions signatures using TError..."
rg -nP 'experimental_liveOptions<[^>]*TError' -S || echo "OK: No experimental_liveOptions<> with TError found."Length of output: 2513
Replace Remaining TError Type Parameters with DefaultError Across All Packages
The search still surfaces experimental_StreamedOptionsIn and experimental_StreamedOptionsBase definitions parameterized by TError in multiple packages. These must be updated to use DefaultError to align with the PR’s intent:
• packages/react-query/src/types.ts (exported at line 22 & 26)
• packages/vue-query/src/types.ts (exported at line 43 & 47)
• packages/svelte-query/src/types.ts (exported at line 30 & 34)
• packages/tanstack-query/src/types.ts (exported at line 60 & 64)
• packages/solid-query/src/types.ts (exported at line 30 & 34)
Please update the generics on both experimental_StreamedOptionsIn<…> and experimental_StreamedOptionsBase<…> in each file to replace TError with DefaultError.
🤖 Prompt for AI Agents
In packages/react-query/src/procedure-utils.ts around lines 46 to 50, and in the
listed files packages/react-query/src/types.ts (exports at lines 22 & 26),
packages/vue-query/src/types.ts (exports at lines 43 & 47),
packages/svelte-query/src/types.ts (exports at lines 30 & 34),
packages/tanstack-query/src/types.ts (exports at lines 60 & 64), and
packages/solid-query/src/types.ts (exports at lines 30 & 34), replace the TError
generic on both experimental_StreamedOptionsIn<...> and
experimental_StreamedOptionsBase<...> with DefaultError; update the type
parameter lists and any usages/exports so those two experimental types are
parameterized by DefaultError instead of TError, ensuring imports for
DefaultError are present if missing and rebuild types to confirm no remaining
TError references.
| import type { Client, ClientContext } from '@orpc/client' | ||
| import type { MaybeOptionalOptions } from '@orpc/shared' | ||
| import type { InfiniteData } from '@tanstack/svelte-query' | ||
| import type { DefaultError, InfiniteData } from '@tanstack/svelte-query' |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Verify DefaultError availability in the targeted Svelte Query version
Importing DefaultError from @tanstack/svelte-query is correct for switching streaming error types. Please verify your peerDependencies/devDependencies pin a version that exports DefaultError to avoid type resolution drift.
Run this script to quickly inspect package constraints across workspaces:
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Checking tanstack deps across packages..."
fd -a package.json packages | while read -r f; do
echo "==> $f"
jq -r '
{
name: .name,
deps: (.dependencies // {}),
peer: (.peerDependencies // {}),
dev: (.devDependencies // {})
}' "$f" | jq '
.name,
.deps["@tanstack/svelte-query"],
.peer["@tanstack/svelte-query"],
.dev["@tanstack/svelte-query"]'
doneLength of output: 14447
Align peerDependencies for DefaultError export
The only package importing DefaultError is packages/svelte-query. Its peerDependencies currently allow
"@tanstack/svelte-query": ">=5.80.2"but your devDependencies pin ^5.85.3, which is likely the first version exporting DefaultError. To avoid type-resolution drift, update the peer range to the minimum version that actually provides DefaultError. For example, in packages/svelte-query/package.json:
"peerDependencies": {
- "@tanstack/svelte-query": ">=5.80.2"
+ "@tanstack/svelte-query": "^5.85.3"
}🤖 Prompt for AI Agents
In packages/svelte-query/src/procedure-utils.ts around line 3, the file imports
DefaultError from @tanstack/svelte-query but the package's peerDependencies
allow versions as low as 5.80.2 which likely don't export DefaultError; update
packages/svelte-query/package.json peerDependencies to require the minimum
version that provides DefaultError (e.g. change the @tanstack/svelte-query range
to >=5.85.3 or ^5.85.3 to match devDependencies), save the file and
reinstall/update lockfile so type resolution is consistent.
|
I think we should validate event iterator error, instead of treat this feature as a bug |
Uses DefaultError instead of TError because TError only applies to the initial request. Streaming errors are not validated, so type safety cannot be guaranteed for error types.
Summary by CodeRabbit
Refactor
Documentation
Tests