| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Sorry, something went wrong.
There was a problem hiding this comment.
Updates the subscriptions documentation and the standalone-server reference project to steer users away from the deprecated @trpc/server/observable API and toward the recommended async function* generator pattern ahead of tRPC v12.
Changes:
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| www/docs/server/subscriptions.md | Adds a caution block warning about @trpc/server/observable deprecation and pointing to the updated example. |
| examples/standalone-server/src/server.ts | Migrates the randomNumber subscription implementation from observable to an async function* generator. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
| :::caution Deprecation Notice | ||
| The `@trpc/server/observable` API is deprecated and will be removed in tRPC v12. | ||
| Please migrate your subscriptions to use `async function*` generators instead. |
| randomNumber: publicProcedure.subscription(async function* ({ signal }) { | ||
| // Loop until the client disconnects and triggers the abort signal | ||
| while (!signal?.aborted) { | ||
| // Yield the random number instead of using emit.next() | ||
| yield { randomNumber: Math.random() }; | ||
|
|
||
| // Wait for 200ms before the next loop instead of using setInterval | ||
| await new Promise((resolve) => setTimeout(resolve, 200)); | ||
| } | ||
| }), |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: a3fb2b70-97d1-4cf3-ae03-02e3c5a40f88 📥 CommitsReviewing files that changed from the base of the PR and between 277f3ee and d770f3e. 📒 Files selected for processing (2)
📝 Walkthrough WalkthroughThe standalone-server example's randomNumber subscription is rewritten from an observable-based implementation to an async generator that yields values until the abort signal fires. The subscriptions documentation adds a deprecation caution for the observable API. ChangesDeprecate observable in favor of async generators
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant Server
participant Signal
Client->>Server: subscribe to randomNumber
loop every 200ms
Server->>Server: yield {randomNumber}
Server->>Client: emit value
end
Client->>Signal: unsubscribe/disconnect
Signal->>Server: abort signal
Server->>Server: exit loop
Possibly related PRs
Suggested labels: ♻️ autoupdate Suggested reviewers: KATT 🚥 Pre-merge checks | ✅ 5 ✅ Passed checks (5 passed)
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. ❤️ ShareComment @coderabbitai help to get the list of available commands. |
Sorry, something went wrong.
There was a problem hiding this comment.
examples/standalone-server/src/server.ts (1)🤖 Prompt for all review comments with AI agents47-47: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Avoid destructuring in the function parameter.
async function* ({ signal }) destructures directly in the parameter declaration. As per coding guidelines: "Never destructure in function parameter declarations." Destructure signal from opts inside the function body instead.
♻️ Proposed fix🤖 Prompt for AI Agents- randomNumber: publicProcedure.subscription(async function* ({ signal }) { + randomNumber: publicProcedure.subscription(async function* (opts) { // Loop until the client disconnects and triggers the abort signal - while (!signal?.aborted) { + while (!opts.signal?.aborted) { // Yield the random number instead of using emit.next() yield { randomNumber: Math.random() };Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@examples/standalone-server/src/server.ts` at line 47, The subscription handler in publicProcedure should not destructure its argument in the async function* parameter list. Update the randomNumber subscription to accept the options object as a single parameter and destructure signal inside the function body instead, so the handler follows the no-destructuring-in-parameters guideline.Source: Coding guidelines
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Nitpick comments: In `@examples/standalone-server/src/server.ts`: - Line 47: The subscription handler in publicProcedure should not destructure its argument in the async function* parameter list. Update the randomNumber subscription to accept the options object as a single parameter and destructure signal inside the function body instead, so the handler follows the no-destructuring-in-parameters guideline.
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d3da6c94-78f7-44d0-b8aa-26f750e54a6b
📥 CommitsReviewing files that changed from the base of the PR and between 340811b and 277f3ee.
📒 Files selected for processing (2)
Sorry, something went wrong.
|
@trpc/client
npm i https://pkg.pr.new/@trpc/client@7429
npm i https://pkg.pr.new/@trpc/next@7429
npm i https://pkg.pr.new/@trpc/openapi@7429
npm i https://pkg.pr.new/@trpc/react-query@7429
npm i https://pkg.pr.new/@trpc/server@7429
npm i https://pkg.pr.new/@trpc/tanstack-react-query@7429
npm i https://pkg.pr.new/@trpc/upgrade@7429 commit: 80e015d |
Sorry, something went wrong.
|
Hi team! I've implemented the fix for #7368 (migrating the standalone-server to async generators and updating the docs). The PR is ready, but it looks like the @trpc/upgrade test/transforms.test.ts > hooks > hooks optimistic-update.tsx test is flaking in the CI pipeline (it passes cleanly on my local machine). Could a maintainer take a look or re-run the failed job when you have a moment? |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Closes #7368
🎯 Changes
This PR replaces the deprecated @trpc/server/observable API with the modern async function* generator pattern in the standalone-server reference project.
Additionally, it adds a deprecation notice to the Subscriptions documentation (www/docs/server/subscriptions.md) to clearly warn users that the observable API will be removed in tRPC v12 and provides instructions to migrate to async generators.
✅ Checklist
Summary by CodeRabbit
Refactor
Documentation