Skip to content

docs: add example of event iterator to playgrounds#1047

Merged
dinwwwh merged 2 commits intomainfrom
docs/add-event-iteartor-example-into-playgrounds
Sep 29, 2025
Merged

docs: add example of event iterator to playgrounds#1047
dinwwwh merged 2 commits intomainfrom
docs/add-event-iteartor-example-into-playgrounds

Conversation

@dinwwwh
Copy link
Copy Markdown
Member

@dinwwwh dinwwwh commented Sep 29, 2025

Summary by CodeRabbit

  • New Features

    • Added Event Iterator streaming examples across all playgrounds, showing live streamed data as pretty-printed JSON.
  • Performance

    • Streaming requests are excluded from batching to improve real-time reliability.
  • UI

    • Added separators to highlight new streaming sections in relevant playground pages.

@vercel
Copy link
Copy Markdown

vercel Bot commented Sep 29, 2025

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

Project Deployment Preview Comments Updated (UTC)
orpc Ready Ready Preview Comment Sep 29, 2025 8:19am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 29, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds EventIteratorQueries streaming UI components across multiple playgrounds that consume oRPC SSE via TanStack Query and renders streamed JSON. Introduces BatchLinkPlugin usage with an exclude rule to skip batching for SSE paths and adds BatchHandlerPlugin to some server RPC handlers. All changes are additive.

Changes

Cohort / File(s) Summary
New streaming demo components (EventIteratorQueries)
playgrounds/astro/src/components/orpc-stream.tsx, playgrounds/browser-extension/entrypoints/popup/components/orpc-stream.tsx, playgrounds/cloudflare-worker/src/components/orpc-stream.tsx, playgrounds/electron/src/renderer/src/components/orpc-stream.tsx, playgrounds/next/src/app/orpc-stream.tsx, playgrounds/solid-start/src/routes/orpc-stream.tsx, playgrounds/svelte-kit/src/routes/orpc-stream.svelte, playgrounds/tanstack-start/src/components/orpc-stream.tsx, playgrounds/nuxt/components/orpc-stream.vue
Add EventIteratorQueries components that call orpc.sse.experimental_streamedOptions({ queryFnOptions: { maxChunks: 3 } }) (via TanStack Query variants) and render streamed.data as pretty-printed JSON.
BatchLinkPlugin client configuration (exclude 'sse')
playgrounds/astro/src/lib/orpc.ts, playgrounds/cloudflare-worker/src/lib/orpc.ts, playgrounds/next/src/lib/orpc.ts, playgrounds/nuxt/plugins/orpc.client.ts, playgrounds/solid-start/src/lib/orpc.ts, playgrounds/svelte-kit/src/lib/orpc.ts, playgrounds/tanstack-start/src/lib/orpc.ts
Wire BatchLinkPlugin into RPCLink configurations and add exclude: ({ path }) => path[0] === 'sse' to prevent batching SSE requests; some clients also define a default batching group. SvelteKit also adds export const orpc = createTanstackQueryUtils(client).
Server-side BatchHandlerPlugin additions
playgrounds/nuxt/server/routes/rpc/[...].ts, playgrounds/solid-start/src/routes/rpc/[...rest].ts, playgrounds/svelte-kit/src/routes/rpc/[...rest]/+server.ts, playgrounds/tanstack-start/src/routes/api/rpc.$.ts
Add BatchHandlerPlugin() to RPC handler plugins; tanstack-start also updates RPCHandler call to pass interceptors/plugins (including onError).
Pages / apps render streaming component
playgrounds/astro/src/pages/index.astro, playgrounds/browser-extension/entrypoints/popup/App.tsx, playgrounds/cloudflare-worker/src/App.tsx, playgrounds/electron/src/renderer/src/App.tsx, playgrounds/next/src/app/page.tsx, playgrounds/solid-start/src/routes/index.tsx, playgrounds/svelte-kit/src/routes/+page.svelte, playgrounds/nuxt/app.vue, playgrounds/tanstack-start/src/routes/index.tsx, playgrounds/svelte-kit/src/routes/+page.svelte, playgrounds/svelte-kit/src/routes/+page.svelte
Import and render the new EventIteratorQueries / OrpcStream components in UI pages (inserted with <hr/> separators); strictly additive UI changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant C as EventIteratorQueries (UI)
  participant Q as TanStack Query
  participant O as oRPC Client
  participant S as Server (SSE)

  U->>C: Open page
  C->>Q: useQuery(streamedOptions)
  Q->>O: Issue SSE request (marked sse)
  O->>S: GET /sse/...
  Note right of S: Server streams chunks
  S-->>O: chunk 1..n
  O-->>Q: forward chunks
  Q-->>C: update cache/state per chunk
  C-->>U: render streamed JSON updates
  S-->>O: stream end
  O-->>Q: finalize
Loading
sequenceDiagram
  participant O as oRPC Client
  participant B as BatchLinkPlugin
  participant S as Server

  O->>B: Outgoing request (path)
  alt path[0] == "sse"
    B-->>O: Exclude from batching
    O->>S: Send request immediately (SSE)
  else
    B->>B: Group/Batch request
    B->>S: Send batched request
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • unnoq/orpc#344 — Related to BatchLinkPlugin orchestration and ordering; touches the same plugin integration surface used here.
  • unnoq/orpc#329 — Adds/changes BatchLinkPlugin/BatchHandlerPlugin implementation that this PR configures (exclude for 'sse').
  • unnoq/orpc#800 — Modifies playground RPC client setup (Cloudflare worker) and exports used alongside the changes in this PR.

Poem

🐇 I hop through code with a curious gleam,
Streaming small chunks of a server-side stream.
“Not for batching,” I nudge with a twitchy nose,
JSON carrots fall into pretty pre rows.
Commit, push, and hop—playgrounds aglow with beams.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title accurately reflects the primary change by stating that an example of the event iterator is being added to the playgrounds, concisely capturing the core purpose of the pull request without unnecessary detail.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs/add-event-iteartor-example-into-playgrounds

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc09277 and e1ca324.

📒 Files selected for processing (4)
  • playgrounds/nuxt/server/routes/rpc/[...].ts (2 hunks)
  • playgrounds/solid-start/src/routes/rpc/[...rest].ts (1 hunks)
  • playgrounds/svelte-kit/src/routes/rpc/[...rest]/+server.ts (1 hunks)
  • playgrounds/tanstack-start/src/routes/api/rpc.$.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
playgrounds/nuxt/server/routes/rpc/[...].ts (1)
packages/server/src/plugins/batch.ts (1)
  • BatchHandlerPlugin (46-194)
playgrounds/solid-start/src/routes/rpc/[...rest].ts (1)
packages/server/src/plugins/batch.ts (1)
  • BatchHandlerPlugin (46-194)
playgrounds/svelte-kit/src/routes/rpc/[...rest]/+server.ts (1)
packages/server/src/plugins/batch.ts (1)
  • BatchHandlerPlugin (46-194)
playgrounds/tanstack-start/src/routes/api/rpc.$.ts (1)
packages/server/src/plugins/batch.ts (1)
  • BatchHandlerPlugin (46-194)
⏰ 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: test
  • GitHub Check: lint
🔇 Additional comments (4)
playgrounds/solid-start/src/routes/rpc/[...rest].ts (1)

6-6: Batch plugin added; confirm SSE isn’t batched

Looks correct. Please ensure client-side BatchLinkPlugin excludes SSE/event-iterator routes in this stack to avoid 500s from batched streams.

Also applies to: 14-16

playgrounds/nuxt/server/routes/rpc/[...].ts (1)

3-3: Batching enabled; double-check client excludes for SSE

Change is good. Verify the Nuxt playground’s client BatchLinkPlugin excludes SSE paths so streamed procedures aren’t batched.

Also applies to: 12-14

playgrounds/tanstack-start/src/routes/api/rpc.$.ts (1)

6-18: Good centralization (onError + batching); confirm SSE exclude on client

Nice consolidation with onError and BatchHandlerPlugin. Please confirm the TanStack Start client excludes SSE/event-iterator routes from batching.

playgrounds/svelte-kit/src/routes/rpc/[...rest]/+server.ts (1)

6-6: Excludes for SSE routes are correctly configured
All playgrounds’ BatchLinkPlugin instances already specify exclude: ({ path }) => path[0] === 'sse', so SSE/event-iterator routes won’t be batched. Optionally add an explicit maxSize to BatchHandlerPlugin for documentation clarity.


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 and usage tips.

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Sep 29, 2025
@gemini-code-assist
Copy link
Copy Markdown
Contributor

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 significantly enhances the documentation and examples within the project's playgrounds by adding a robust demonstration of oRPC's experimental event iterator for streaming data. By integrating this functionality with Tanstack Query across various frontend frameworks, it provides a clear and practical guide for developers looking to implement real-time data streaming. The changes also include necessary adjustments to the oRPC client configurations to ensure proper handling of streaming requests, thereby improving the overall functionality and educational value of the playgrounds.

Highlights

  • New Event Iterator Example Components: Introduced dedicated EventIteratorQueries (or OrpcStream) components across all playgrounds (Astro, Browser Extension, Cloudflare Worker, Electron, Next.js, Nuxt, SolidStart, SvelteKit, Tanstack Start) to demonstrate oRPC's experimental event iterator for streaming data with Tanstack Query.
  • Integration into Playgrounds: The newly created streaming examples have been seamlessly integrated into the main application pages of each respective playground, making them easily accessible for testing and demonstration.
  • oRPC Client Configuration Update: Modified the oRPC client configurations in several playgrounds to explicitly exclude sse (Server-Sent Events) paths from batching. This ensures that streaming requests are handled individually, preventing potential conflicts or delays that could arise from batching streaming connections.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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 adds examples for event iterators to various playground applications. The changes are consistent across the different frameworks, demonstrating how to use oRPC streaming with Tanstack Query. The configuration is also updated to exclude streaming endpoints from request batching, which is correct. I've found one issue with the useQuery hook usage in the Astro playground and a minor formatting issue in the Svelte example. Otherwise, the changes look good.

Comment thread playgrounds/astro/src/components/orpc-stream.tsx
Comment thread playgrounds/svelte-kit/src/routes/orpc-stream.svelte
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Sep 29, 2025

More templates

@orpc/arktype

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

@orpc/client

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

@orpc/contract

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

@orpc/experimental-durable-iterator

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

@orpc/hey-api

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

@orpc/interop

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

@orpc/json-schema

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

@orpc/nest

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

@orpc/openapi

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

@orpc/openapi-client

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

@orpc/otel

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

@orpc/react

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

@orpc/react-query

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

@orpc/experimental-react-swr

npm i https://pkg.pr.new/@orpc/experimental-react-swr@1047

@orpc/server

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

@orpc/shared

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

@orpc/solid-query

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

@orpc/standard-server

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

@orpc/standard-server-aws-lambda

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

@orpc/standard-server-fetch

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

@orpc/standard-server-node

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

@orpc/standard-server-peer

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

@orpc/svelte-query

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

@orpc/tanstack-query

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

@orpc/trpc

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

@orpc/valibot

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

@orpc/vue-colada

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

@orpc/vue-query

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

@orpc/zod

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

commit: e1ca324

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 (15)
playgrounds/cloudflare-worker/src/lib/orpc.ts (1)

16-22: Exclude predicate hardening + plugin ordering check with DurableIterator.

  • Harden exclude as in other files to handle non‑array path and fall back to URL/Accept.
  • Minor: confirm BatchLinkPlugin runs before any plugin that might transform SSE requests. If plugin ordering is by plugin.order, BatchLinkPlugin has order 5_000_000; ensure DurableIteratorLinkPlugin doesn’t register a higher-priority interceptor that would rely on batching decisions.

Proposed exclude:

-    new BatchLinkPlugin({
-      exclude: ({ path }) => path[0] === 'sse',
+    new BatchLinkPlugin({
+      exclude: ({ path, request }) => {
+        const seg0 = Array.isArray(path) ? path[0] : String(path ?? '').split(/[.//]/)[0]
+        const isSsePath = seg0 === 'sse' || request.url.includes('/sse/')
+        const acceptsSse =
+          typeof request.headers['accept'] === 'string' &&
+          request.headers['accept'].includes('text/event-stream')
+        return isSsePath || acceptsSse
+      },

To verify relative ordering, please confirm the DurableIterator plugin’s interceptor order (or share its order value). Based on learnings.

playgrounds/nuxt/plugins/orpc.client.ts (1)

12-20: Defensive exclude for SSE and brief inline comment.

Guard for string/undefined path and document the intent so future edits don’t break streaming demos.

-      new BatchLinkPlugin({
-        exclude: ({ path }) => path[0] === 'sse',
+      new BatchLinkPlugin({
+        // Never batch SSE endpoints; keep streaming semantics intact
+        exclude: ({ path, request }) => {
+          const seg0 = Array.isArray(path) ? path[0] : String(path ?? '').split(/[.//]/)[0]
+          return seg0 === 'sse'
+            || request.url.includes('/sse/')
+            || (typeof request.headers['accept'] === 'string'
+                && request.headers['accept'].includes('text/event-stream'))
+        },

Based on learnings.

playgrounds/astro/src/lib/orpc.ts (1)

12-17: Robust exclude for SSE to avoid accidental batching regressions.

Replicate the hardened predicate so it keeps working if path becomes a string or URL format changes.

-      exclude: ({ path }) => path[0] === 'sse',
+      exclude: ({ path, request }) => {
+        const seg0 = Array.isArray(path) ? path[0] : String(path ?? '').split(/[.//]/)[0]
+        return seg0 === 'sse'
+          || request.url.includes('/sse/')
+          || (typeof request.headers['accept'] === 'string'
+              && request.headers['accept'].includes('text/event-stream'))
+      },

Based on learnings.

playgrounds/next/src/lib/orpc.ts (1)

20-26: Make the exclude predicate resilient to string path and cover SSE requests
Guard against non-array path values and also check the request URL or Accept header for SSE.

 playgrounds/next/src/lib/orpc.ts
@@ -18,7 +18,20 @@ const link = new RPCLink({
     plugins: [
       new BatchLinkPlugin({
-        exclude: ({ path }) => path[0] === 'sse',
+        exclude: ({ path, request }) => {
+          const seg0 = Array.isArray(path)
+            ? path[0]
+            : String(path ?? '').split(/[.\\/]/)[0] // handles 'sse.foo' or 'sse/foo'
+          const isSsePath = seg0 === 'sse' || request.url.includes('/sse/')
+          const acceptsSse =
+            typeof request.headers['accept'] === 'string' &&
+            request.headers['accept'].includes('text/event-stream')
+          return isSsePath || acceptsSse
+        },
         groups: [{
           condition: () => true,
           context: {},
         }],
       }),
playgrounds/tanstack-start/src/lib/orpc.ts (1)

34-39: LGTM; optional SSE detection enhancement

Consider expanding the exclude callback to fall back on the request URL or Accept header when path isn’t an array:

-          exclude: ({ path }) => path[0] === 'sse',
+          exclude: ({ path, request }) => {
+            const seg0 = Array.isArray(path)
+              ? path[0]
+              : String(path ?? '').split(/[.//]/)[0];
+            return seg0 === 'sse'
+              || request.url.includes('/sse/')
+              || (typeof request.headers['accept'] === 'string'
+                  && request.headers['accept'].includes('text/event-stream'));
+          },
playgrounds/astro/src/components/orpc-stream.tsx (1)

5-16: Tighten UX and fix heading style
Add loading/error handling and correct “Tanstack” → “TanStack”. QueryClient is already a stable singleton and SSE is excluded from batching—no further changes needed there.

Apply:

 export function EventIteratorQueries() {
-  const streamed = useQuery(orpc.sse.experimental_streamedOptions({ queryFnOptions: { maxChunks: 3 } }), queryClient)
+  const streamed = useQuery(orpc.sse.experimental_streamedOptions({ queryFnOptions: { maxChunks: 3 } }), queryClient)
+  const { data, isPending, error } = streamed

   return (
     <div>
-      <h2>oRPC and Tanstack Query | Event Iterator example</h2>
+      <h2>oRPC and TanStack Query | Event Iterator example</h2>
       <pre>
-        {JSON.stringify(streamed.data, null, 2)}
+        {isPending
+          ? 'Loading…'
+          : error
+          ? String(error)
+          : JSON.stringify(data ?? 'No data yet', null, 2)}
       </pre>
     </div>
   )
 }
playgrounds/svelte-kit/src/routes/orpc-stream.svelte (1)

13-18: Add basic loading/error states for a clearer demo

Surface pending/error to avoid showing empty JSON during fetch or on failures.

 <div>
   <h2>oRPC and Tanstack Query | Event Iterator example</h2>
-  <pre>
-{JSON.stringify($streamed.data, null, 2)}
-  </pre>
+  {#if $streamed.isPending}
+    <pre>Loading…</pre>
+  {:else if $streamed.error}
+    <pre class="error">{String($streamed.error)}</pre>
+  {:else}
+    <pre>{JSON.stringify($streamed.data, null, 2)}</pre>
+  {/if}
 </div>  
playgrounds/svelte-kit/src/lib/orpc.ts (1)

14-20: Optional: document mode for clarity

BatchLinkPlugin defaults to mode: 'streaming'. Consider setting it explicitly to self-document intended behavior.

 new BatchLinkPlugin({
   exclude: ({ path }) => path[0] === 'sse',
+  mode: 'streaming',
   groups: [{
     condition: () => true,
     context: {},
   }],
 }),
playgrounds/cloudflare-worker/src/components/orpc-stream.tsx (1)

7-14: Show loading/error to improve the example UX

React Query exposes status flags; render them for a clearer streaming demo.

   return (
     <div>
       <h2>oRPC and Tanstack Query | Event Iterator example</h2>
-      <pre>
-        {JSON.stringify(streamed.data, null, 2)}
-      </pre>
+      <pre>
+        {streamed.isPending
+          ? 'Loading…'
+          : streamed.error
+          ? String(streamed.error)
+          : JSON.stringify(streamed.data, null, 2)}
+      </pre>
     </div>
   )
playgrounds/solid-start/src/routes/orpc-stream.tsx (1)

9-16: Optional: add pending/error UI like other demos

Parity with React/Svelte examples makes the demo clearer.

   return (
     <div>
       <h2>oRPC and Tanstack Query | Event Iterator example</h2>
-      <pre>
-        {JSON.stringify(streamed.data, null, 2)}
-      </pre>
+      <pre>
+        {streamed.isPending
+          ? 'Loading…'
+          : streamed.error
+          ? String(streamed.error)
+          : JSON.stringify(streamed.data, null, 2)}
+      </pre>
     </div>
   )
playgrounds/nuxt/components/orpc-stream.vue (1)

6-8: Add basic loading/error UI and avoid SSE refetch on window focus.

  • Streaming demos benefit from showing pending/error states to clarify behavior.
  • Consider disabling refetchOnWindowFocus to prevent restarting the stream when tab focuses.

Example (adjust to your integration surface):

  • Add UI: query.isPending ? 'Loading…' : JSON.
  • Set refetchOnWindowFocus: false via your query options/config.

Please confirm where you prefer to pass refetchOnWindowFocus: false (inside experimental_streamedOptions if supported, or via QueryClient defaults for demos).

Also applies to: 12-18

playgrounds/solid-start/src/lib/orpc.ts (1)

21-27: Optional: Consider grouping batches more narrowly.

groups: [{ condition: () => true }] will batch all eligible requests together. If you anticipate varied headers/contexts or large concurrent volumes, consider grouping by path or method to keep batches smaller and more coherent.

Is global batching intentional for this playground, or would grouping by first path segment be preferable?

playgrounds/tanstack-start/src/components/orpc-stream.tsx (1)

4-15: Provide loading/error states and stabilize UX for streaming.

  • Show streamed.isPending/isError UI to make the example clearer.
  • Consider refetchOnWindowFocus: false to avoid restarting the stream on focus.
playgrounds/next/src/app/orpc-stream.tsx (1)

6-16: Minor UX: prevent refetch-on-focus for SSE and add basic status UI.

Next.js client components often regain focus during hot reload/navigation, which can restart SSE queries. Consider refetchOnWindowFocus: false and simple loading/error messages for the demo.

Confirm whether your experimental_streamedOptions API supports merging additional TanStack options directly; if not, set this via QueryClient defaults for the demo page.

playgrounds/electron/src/renderer/src/components/orpc-stream.tsx (1)

4-15: Demo polish: add loading/error UI; consider disabling refetch on focus.

Electron windows can frequently gain/lose focus; disable refetch-on-focus for smoother streaming and display basic isPending/isError states.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db61815 and cc09277.

📒 Files selected for processing (25)
  • playgrounds/astro/src/components/orpc-stream.tsx (1 hunks)
  • playgrounds/astro/src/lib/orpc.ts (1 hunks)
  • playgrounds/astro/src/pages/index.astro (2 hunks)
  • playgrounds/browser-extension/entrypoints/popup/App.tsx (2 hunks)
  • playgrounds/browser-extension/entrypoints/popup/components/orpc-stream.tsx (1 hunks)
  • playgrounds/cloudflare-worker/src/App.tsx (2 hunks)
  • playgrounds/cloudflare-worker/src/components/orpc-stream.tsx (1 hunks)
  • playgrounds/cloudflare-worker/src/lib/orpc.ts (2 hunks)
  • playgrounds/electron/src/renderer/src/App.tsx (2 hunks)
  • playgrounds/electron/src/renderer/src/components/orpc-stream.tsx (1 hunks)
  • playgrounds/next/src/app/orpc-stream.tsx (1 hunks)
  • playgrounds/next/src/app/page.tsx (2 hunks)
  • playgrounds/next/src/lib/orpc.ts (1 hunks)
  • playgrounds/nuxt/app.vue (1 hunks)
  • playgrounds/nuxt/components/orpc-stream.vue (1 hunks)
  • playgrounds/nuxt/plugins/orpc.client.ts (1 hunks)
  • playgrounds/solid-start/src/lib/orpc.ts (2 hunks)
  • playgrounds/solid-start/src/routes/index.tsx (2 hunks)
  • playgrounds/solid-start/src/routes/orpc-stream.tsx (1 hunks)
  • playgrounds/svelte-kit/src/lib/orpc.ts (1 hunks)
  • playgrounds/svelte-kit/src/routes/+page.svelte (2 hunks)
  • playgrounds/svelte-kit/src/routes/orpc-stream.svelte (1 hunks)
  • playgrounds/tanstack-start/src/components/orpc-stream.tsx (1 hunks)
  • playgrounds/tanstack-start/src/lib/orpc.ts (1 hunks)
  • playgrounds/tanstack-start/src/routes/index.tsx (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (17)
playgrounds/tanstack-start/src/routes/index.tsx (1)
playgrounds/tanstack-start/src/components/orpc-stream.tsx (1)
  • EventIteratorQueries (4-15)
playgrounds/cloudflare-worker/src/lib/orpc.ts (1)
packages/client/src/plugins/batch.ts (1)
  • BatchLinkPlugin (75-310)
playgrounds/cloudflare-worker/src/components/orpc-stream.tsx (2)
playgrounds/astro/src/components/orpc-stream.tsx (1)
  • EventIteratorQueries (5-16)
playgrounds/cloudflare-worker/src/lib/orpc.ts (1)
  • orpc (28-28)
playgrounds/tanstack-start/src/components/orpc-stream.tsx (1)
playgrounds/tanstack-start/src/lib/orpc.ts (1)
  • orpc (48-48)
playgrounds/electron/src/renderer/src/components/orpc-stream.tsx (12)
playgrounds/astro/src/components/orpc-stream.tsx (1)
  • EventIteratorQueries (5-16)
playgrounds/browser-extension/entrypoints/popup/components/orpc-stream.tsx (1)
  • EventIteratorQueries (4-15)
playgrounds/cloudflare-worker/src/components/orpc-stream.tsx (1)
  • EventIteratorQueries (4-15)
playgrounds/next/src/app/orpc-stream.tsx (1)
  • EventIteratorQueries (6-17)
playgrounds/solid-start/src/routes/orpc-stream.tsx (1)
  • EventIteratorQueries (4-17)
playgrounds/tanstack-start/src/components/orpc-stream.tsx (1)
  • EventIteratorQueries (4-15)
playgrounds/astro/src/lib/orpc.ts (1)
  • orpc (23-23)
playgrounds/cloudflare-worker/src/lib/orpc.ts (1)
  • orpc (28-28)
playgrounds/next/src/lib/orpc.ts (1)
  • orpc (32-32)
playgrounds/solid-start/src/lib/orpc.ts (1)
  • orpc (33-33)
playgrounds/svelte-kit/src/lib/orpc.ts (1)
  • orpc (26-26)
playgrounds/tanstack-start/src/lib/orpc.ts (1)
  • orpc (48-48)
playgrounds/solid-start/src/lib/orpc.ts (1)
packages/client/src/plugins/batch.ts (1)
  • BatchLinkPlugin (75-310)
playgrounds/nuxt/plugins/orpc.client.ts (1)
packages/client/src/plugins/batch.ts (1)
  • BatchLinkPlugin (75-310)
playgrounds/astro/src/components/orpc-stream.tsx (3)
playgrounds/browser-extension/entrypoints/popup/components/orpc-stream.tsx (1)
  • EventIteratorQueries (4-15)
playgrounds/solid-start/src/routes/orpc-stream.tsx (1)
  • EventIteratorQueries (4-17)
playgrounds/astro/src/lib/orpc.ts (1)
  • orpc (23-23)
playgrounds/browser-extension/entrypoints/popup/App.tsx (1)
playgrounds/browser-extension/entrypoints/popup/components/orpc-stream.tsx (1)
  • EventIteratorQueries (4-15)
playgrounds/solid-start/src/routes/index.tsx (1)
playgrounds/solid-start/src/routes/orpc-stream.tsx (1)
  • EventIteratorQueries (4-17)
playgrounds/browser-extension/entrypoints/popup/components/orpc-stream.tsx (4)
playgrounds/astro/src/components/orpc-stream.tsx (1)
  • EventIteratorQueries (5-16)
playgrounds/cloudflare-worker/src/components/orpc-stream.tsx (1)
  • EventIteratorQueries (4-15)
playgrounds/solid-start/src/routes/orpc-stream.tsx (1)
  • EventIteratorQueries (4-17)
playgrounds/cloudflare-worker/src/lib/orpc.ts (1)
  • orpc (28-28)
playgrounds/solid-start/src/routes/orpc-stream.tsx (2)
playgrounds/astro/src/components/orpc-stream.tsx (1)
  • EventIteratorQueries (5-16)
playgrounds/solid-start/src/lib/orpc.ts (1)
  • orpc (33-33)
playgrounds/electron/src/renderer/src/App.tsx (1)
playgrounds/electron/src/renderer/src/components/orpc-stream.tsx (1)
  • EventIteratorQueries (4-15)
playgrounds/cloudflare-worker/src/App.tsx (1)
playgrounds/cloudflare-worker/src/components/orpc-stream.tsx (1)
  • EventIteratorQueries (4-15)
playgrounds/next/src/app/page.tsx (1)
playgrounds/next/src/app/orpc-stream.tsx (1)
  • EventIteratorQueries (6-17)
playgrounds/svelte-kit/src/lib/orpc.ts (1)
packages/client/src/plugins/batch.ts (1)
  • BatchLinkPlugin (75-310)
playgrounds/next/src/app/orpc-stream.tsx (1)
playgrounds/next/src/lib/orpc.ts (1)
  • orpc (32-32)
⏰ 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). (2)
  • GitHub Check: lint
  • GitHub Check: publish-commit
🔇 Additional comments (11)
playgrounds/astro/src/pages/index.astro (1)

16-17: Astro wiring LGTM

Import + client:only usage are consistent with your other components.

If you ever switch this island to share cache with others, consider wrapping a parent on the page to avoid multiple clients.

playgrounds/browser-extension/entrypoints/popup/App.tsx (1)

13-15: QueryClientProvider is correctly integrated in the popup entrypoint
main.tsx imports QueryClient/QueryClientProvider, creates a queryClient, and wraps the app in <QueryClientProvider>, so useQuery will function as expected.

playgrounds/browser-extension/entrypoints/popup/components/orpc-stream.tsx (1)

4-15: Add basic loading/error states and fix “TanStack” capitalization

Consider a minimal UX pass so the example doesn’t render “undefined” while loading and surfaces errors, and update “Tanstack” to “TanStack”:

 export function EventIteratorQueries() {
-  const streamed = useQuery(orpc.sse.experimental_streamedOptions({ queryFnOptions: { maxChunks: 3 } }))
+  const streamed = useQuery(orpc.sse.experimental_streamedOptions({ queryFnOptions: { maxChunks: 3 } }))
+  const { data, isPending, error } = streamed

   return (
     <div>
-      <h2>oRPC and Tanstack Query | Event Iterator example</h2>
+      <h2>oRPC and TanStack Query | Event Iterator example</h2>
       <pre>
-        {JSON.stringify(streamed.data, null, 2)}
+        {isPending ? 'Loading…' : error ? String(error) : JSON.stringify(data ?? 'No data yet', null, 2)}
       </pre>
     </div>
   )
 }

Please confirm that your oRPC client setup (in the browser-extension) explicitly excludes SSE endpoints from the batch-link plugin, so that streamed requests aren’t inadvertently batched.

playgrounds/electron/src/renderer/src/App.tsx (1)

13-14: No BatchLinkPlugin in Electron renderer oRPC client; SSE routes are inherently excluded from batching.

playgrounds/svelte-kit/src/routes/+page.svelte (1)

5-5: SvelteKit streaming example wired correctly

Import path and placement under QueryClientProvider look good and consistent with existing sections.

Also applies to: 24-26

playgrounds/cloudflare-worker/src/App.tsx (1)

6-6: Cloudflare Worker: Streaming sample added cleanly

Import and render order are consistent with the rest of the page. Looks good.

Also applies to: 35-36

playgrounds/tanstack-start/src/routes/index.tsx (1)

4-4: TanStack Start: Clean addition

Import path and placement are consistent with existing sections. No issues.

Also applies to: 23-24

playgrounds/nuxt/app.vue (1)

13-16: Nuxt: OrpcStream component found and will be auto-registered

playgrounds/solid-start/src/routes/index.tsx (1)

20-21: LGTM: clean integration of the streaming demo

Import and render look correct; no side effects on existing UI.

Also applies to: 3-3

playgrounds/svelte-kit/src/lib/orpc.ts (1)

13-21: SSE exclusion is correctly configured. Top-level router namespace is sse, so path[0] === 'sse' will bypass batching as intended.

playgrounds/solid-start/src/lib/orpc.ts (1)

20-28: Remove unnecessary string guard
The path parameter in BatchLinkPlugin’s exclude callback is always a string[] (e.g. the official docs call path.join('/') on it) (orpc.unnoq.com), so checking path[0] === 'sse' already tests the first segment correctly.

Likely an incorrect or invalid review comment.

Comment thread playgrounds/next/src/app/page.tsx
Comment thread playgrounds/solid-start/src/routes/orpc-stream.tsx
@dinwwwh dinwwwh merged commit b9060f2 into main Sep 29, 2025
11 checks passed
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.

1 participant