Skip to content

fix(tanstack-query): correct error type on streamed and live options#892

Closed
dinwwwh wants to merge 1 commit intomainfrom
fix/tanstack-query/incorrect-errors-types-on-streamed-and-live-options
Closed

fix(tanstack-query): correct error type on streamed and live options#892
dinwwwh wants to merge 1 commit intomainfrom
fix/tanstack-query/incorrect-errors-types-on-streamed-and-live-options

Conversation

@dinwwwh
Copy link
Copy Markdown
Member

@dinwwwh dinwwwh commented Aug 18, 2025

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

    • Simplified TypeScript error typing for streaming/live query utilities across React, Solid, Svelte, Vue, and Angular to use the standard Error (DefaultError) instead of mapped error types. Affects streamed/live keys and options; non-streamed queries and mutations unchanged. No runtime behavior changes.
  • Documentation

    • Added notes clarifying that streaming errors use DefaultError and aren’t type-validated like initial request errors.
  • Tests

    • Updated type tests to expect Error for error values and callback parameters in streaming/live scenarios.

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.
@dinwwwh dinwwwh requested a review from Copilot August 18, 2025 10:04
@vercel
Copy link
Copy Markdown

vercel Bot commented Aug 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
orpc Ready Ready Preview Comment Aug 18, 2025 10:08am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 18, 2025

Walkthrough

Error 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

Cohort / File(s) Summary of Changes
React Query: streamed error typing + tests
packages/react-query/src/procedure-utils.ts, packages/react-query/src/procedure-utils.test-d.ts, packages/react-query/tests/e2e.test-d.ts
Switch experimental_streamedOptions error type from TError to DefaultError; add remarks about streaming errors. Update test type assertions to expect Error instead of mapped error types; simplify error-branch checks.
Solid Query: streamed error typing + tests
packages/solid-query/src/procedure-utils.ts, packages/solid-query/src/procedure-utils.test-d.ts, packages/solid-query/tests/e2e.test-d.ts
Import DefaultError and use it in experimental_streamedOptions input/return types; add doc remark. Update tests to assert Error for query.error and callback params across streamed/useQueries paths.
Svelte Query: streamed error typing + tests
packages/svelte-query/src/procedure-utils.ts, packages/svelte-query/src/procedure-utils.test-d.ts, packages/svelte-query/tests/e2e.test-d.ts
Use DefaultError for streaming options’ error type; add doc remark. Replace UtilsError/mapped errors with Error in tests across query/streamed/infinite/mutation scenarios.
Vue Query: streamed error typing + tests
packages/vue-query/src/procedure-utils.ts, packages/vue-query/src/procedure-utils.test-d.ts, packages/vue-query/tests/e2e.test-d.ts
Shift experimental_streamedOptions to DefaultError in parameter and return types; add doc remark. Broaden tests to assert Error for errors in streamed/useQueries and related retry handlers.
TanStack Query core: streamed/live error typing + tests
packages/tanstack-query/src/procedure-utils.ts
Change experimental_streamedKey/Options and experimental_liveKey/Options to use DefaultError instead of TError; import DefaultError; add remarks.
TanStack Query tests (framework variants + e2e)
packages/tanstack-query/src/procedure-utils.react.test-d.ts, ...solid.test-d.ts, ...svelte.test-d.ts, ...vue.test-d.ts, packages/tanstack-query/src/procedure-utils.test-d.ts, packages/tanstack-query/tests/e2e.test-d.ts
Replace UtilsError expectations with Error across query/streamed/live/infinite/mutation tests; adjust getQueryState error typing to Error

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • unnoq/orpc#557 — Similar switch to DefaultError for streamed/live paths and aligned test updates.
  • unnoq/orpc#516 — Introduced experimental streamed/live options that this PR’s type changes modify.
  • unnoq/orpc#311 — Adjusted error typing constraints; related to this PR’s broadening to DefaultError/Error.

Suggested labels

size:XL

Suggested reviewers

  • LouisHaftmann

Poem

In streams I hop, through errors I peer,
DefaultError now, the typing is clear.
No maps to chase, no codes to decode,
Just Error, dear devs, along the load.
With whiskers twitching, I merge and cheer —
Thump-thump! The patch is crystal here. 🐇✨

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 Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/tanstack-query/incorrect-errors-types-on-streamed-and-live-options

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (or Error in test contexts) across all Tanstack Query integrations.
  • Improved Type Safety: The previous TError type 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) in react-query, solid-query, svelte-query, tanstack-query, and vue-query packages 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

  1. 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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
expectTypeOf(queries.value[0].error).toEqualTypeOf<null | Error>()
expectTypeOf(queries.value[1].error).toEqualTypeOf<null | Error>()

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Aug 18, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TError to DefaultError for 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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Aug 18, 2025

More templates

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@892

@orpc/client

npm i https://pkg.pr.new/@orpc/client@892

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@892

@orpc/experimental-durable-event-iterator

npm i https://pkg.pr.new/@orpc/experimental-durable-event-iterator@892

@orpc/hey-api

npm i https://pkg.pr.new/@orpc/hey-api@892

@orpc/interop

npm i https://pkg.pr.new/@orpc/interop@892

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@892

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@892

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@892

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@892

@orpc/otel

npm i https://pkg.pr.new/@orpc/otel@892

@orpc/react

npm i https://pkg.pr.new/@orpc/react@892

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@892

@orpc/server

npm i https://pkg.pr.new/@orpc/server@892

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@892

@orpc/solid-query

npm i https://pkg.pr.new/@orpc/solid-query@892

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@892

@orpc/standard-server-aws-lambda

npm i https://pkg.pr.new/@orpc/standard-server-aws-lambda@892

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@892

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@892

@orpc/standard-server-peer

npm i https://pkg.pr.new/@orpc/standard-server-peer@892

@orpc/svelte-query

npm i https://pkg.pr.new/@orpc/svelte-query@892

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@892

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@892

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@892

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@892

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@892

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@892

commit: 4942072

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 UtilsError

Since getQueryState now widens the error type to Error, the corresponding streaming/live option tests should align with this change. Please update the generic on QueryObserverOptions in 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.code
packages/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” reference

The 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].error

There 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 doc

Minor 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 doc

Same 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 doc

Minor 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/live

Since 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 3b7800f and 4942072.

📒 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 intent

Switching 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 simplification

Checking 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 — consistent

The throwOnError/Retry expectation generalized to Error is consistent with the streaming error policy.


160-162: useQueries streamed error is Error — consistent

Asserting 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 — consistent

Updating state?.error to Error | null | undefined for streamedKey matches the DefaultError approach. Good change.


294-298: .streamedOptions getQueryState error widened to Error — consistent

This matches the intent for streaming errors to be unvalidated (DefaultError). Good.


346-350: .liveKey getQueryState error widened to Error — consistent

Aligns 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 — consistent

Both query.error and throwOnError are generalized to Error. Alignment looks correct.


215-222: Streamed useQueries: error tuples now null | Error — consistent

All entries updated to null | Error. Good coverage.


242-245: Streamed useSuspenseQueries: error tuples now null | Error — consistent

Matches the policy for streaming error typing.


259-273: Live useQuery: error and throwOnError now Error — correct

Generalization to Error aligns with live error semantics.


286-312: Live useSuspenseQuery: error typed as Error — consistent

All assertions updated to Error; good alignment.


333-336: Live useQueries: errors now null | Error — consistent

Consistent with the rest of the streaming/live updates.


356-359: Live useSuspenseQueries: errors now null | Error — consistent

Looks 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 — consistent

Even with initialData + select, error typing remains Error | null. Good.


147-149: Streamed useQueries (Vue): items’ errors now null | Error — consistent

Updated across all query entries. Good.


167-180: Live useQuery (Vue): error and throwOnError now Error — correct

Generalization to Error aligns with the live error contract.


188-191: Live useQuery with initialData: error is Error — consistent

Remains Error | null with initialData + select. Good.


213-215: Live useQueries (Vue): errors now null | Error — consistent

Matches 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 — consistent

Good alignment.


224-226: Streamed useQueries (Solid): errors now null | Error — consistent

Matches 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’s experimental_streamedOptions/experimental_liveOptions uses DefaultError, and no .test-d.ts files assert on the old Error type. 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 correct

Switching the streamed retry callback error typing to Error aligns with DefaultError usage for streaming. Looks good.


122-124: Streamed error branch now expects Error — LGTM

Asserting query.error is Error in the streamed path matches the new DefaultError typing strategy.


152-156: useQueries streamed retry callback now typed as Error — LGTM

The retry callback error parameter typed as Error is consistent with non-validated streaming errors.


164-166: Streamed useQueries error type normalized to Error — LGTM

Checking 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 options

Pulling 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 — LGTM

The query state error shape matches DefaultError in TanStack Query.


194-197: Retry error in streamed options standardized to Error

Good alignment with DefaultError on the streamed path.


201-203: Streamed useQuery error branch now Error — LGTM

This matches the new default streaming error typing.


229-237: Suspense streamed retry/error typing normalized to Error

Both the retry callback and the status 'error' branch typing look correct.


264-277: useQueries streamed typing uses Error — LGTM

Uniform Error typing for retry callback and error branch is consistent and correct.


299-312: useSuspenseQueries streamed typing uses Error — LGTM

Consistent 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 — LGTM

Correctly reflects DefaultError on the streaming path.


227-228: useQuery streamed error.value typed as Error | null — LGTM

Matches the normalized streaming error type.


235-236: throwOnError(error) remains Error with initialData — LGTM

Consistent with streamed error typing.


241-242: useQuery streamed error.value typed as Error | null (with initialData) — LGTM

packages/tanstack-query/src/procedure-utils.angular.test-d.ts (5)

100-112: Streamed injectQuery now expects Error — LGTM

Moving error()/throwOnError(error) to Error for streamed options is consistent with DefaultError semantics.


145-148: injectQueries streamed errors typed as Error — LGTM

All queries’ error types normalized to Error in streamed context; looks good.


164-176: liveOptions injectQuery errors typed as Error — LGTM

Error 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 — LGTM

Normalization 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 DefaultError

Using 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 version

Import 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 DefaultError

The 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 DefaultError

Matching 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-core is declared as:
    • peerDependency: >=5.80.2
    • devDependency: ^5.85.3

These bounds ensure that DefaultError is 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 version

The 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 DefaultError

Input 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 surfaces

Switching 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 | null

These expectations align with the new DefaultError-typed DataTag and QueryOptionsBase error surfaces.


156-170: LGTM: Live options assert Error for error surfaces

The liveOptions tests mirror the streamedOptions changes and look correct.

Comment on lines 46 to 50
...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>>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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"]'
done

Length 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.

@dinwwwh
Copy link
Copy Markdown
Member Author

dinwwwh commented Aug 18, 2025

I think we should validate event iterator error, instead of treat this feature as a bug

@dinwwwh dinwwwh closed this Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants