-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(client): ending a stream with the correct error #6462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis pull request refines error management across client and server packages. The error message in Changes
Sequence Diagram(s)sequenceDiagram
participant C as Client
participant AC as AbortController
participant S as Streaming Server
participant E as Error Handler
C->>S: Initiate streaming query
C->>AC: Signal abort
AC->>S: Propagate abort signal
S->>E: Detect streaming interruption
E-->>C: Return AbortError / TRPCClientError
Assessment against linked issues
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🔇 Additional comments (5)
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
🚅 Previously deployed to Railway in the trpc-sse-and-websockets project. Environment has been deleted. |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/tests/server/regression/issue-6461-stream-error.test.ts (1)
11-18: Consider adding a timeout or max iterations to prevent resource exhaustion.The infinite loop with a 1ms delay might be too aggressive for testing. Consider:
- Adding a maximum number of iterations
- Increasing the delay between yields
- Adding a timeout mechanism
const appRouter = t.router({ stream: t.procedure.query(async function* () { + const MAX_ITERATIONS = 1000; + const YIELD_DELAY_MS = 10; + let iterations = 0; while (true) { + if (iterations++ >= MAX_ITERATIONS) { + break; + } yield 'tick'; - await new Promise((resolve) => setTimeout(resolve, 1)); + await new Promise((resolve) => setTimeout(resolve, YIELD_DELAY_MS)); } }), });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
packages/client/src/links/httpBatchStreamLink.ts(1 hunks)packages/server/src/unstable-core-do-not-import/stream/jsonl.test.ts(3 hunks)packages/server/src/unstable-core-do-not-import/stream/jsonl.ts(6 hunks)packages/tests/server/regression/issue-6461-stream-error.test.ts(1 hunks)packages/tests/server/streaming.test.ts(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- packages/client/src/links/httpBatchStreamLink.ts
⏰ Context from checks skipped due to timeout of 90000ms (20)
- GitHub Check: E2E-tests (fastify-server)
- GitHub Check: E2E-tests (express-server)
- GitHub Check: E2E-tests (express-minimal)
- GitHub Check: e2e-legacy-node (next-prisma-todomvc, 20.x)
- GitHub Check: E2E-tests (cloudflare-workers)
- GitHub Check: e2e-legacy-node (next-prisma-todomvc, 18.x)
- GitHub Check: E2E-tests (.test/ssg)
- GitHub Check: e2e-legacy-node (next-prisma-websockets-starter, 20.x)
- GitHub Check: E2E-tests (.test/internal-types-export)
- GitHub Check: Release using pkg.pr.new
- GitHub Check: e2e-legacy-node (next-prisma-websockets-starter, 18.x)
- GitHub Check: E2E-tests (.test/diagnostics-big-router)
- GitHub Check: Test a monorepo using built declaration files
- GitHub Check: e2e-legacy-node (next-prisma-starter, 20.x)
- GitHub Check: E2E-tests (.experimental/next-app-dir)
- GitHub Check: e2e-legacy-node (next-prisma-starter, 18.x)
- GitHub Check: E2E-tests (Bun) (bun, ubuntu-latest)
- GitHub Check: E2E-tests (Deno) (deno-deploy)
- GitHub Check: Lint and auto-fix
- GitHub Check: test
🔇 Additional comments (7)
packages/tests/server/regression/issue-6461-stream-error.test.ts (2)
1-18: LGTM! Well-structured test setup.The imports and router setup are clean and follow best practices.
20-46: LGTM! Well-structured test for stream interruption.The test effectively verifies that:
- Stream interruption is handled correctly
- AbortController works as expected
- Error is propagated properly
packages/server/src/unstable-core-do-not-import/stream/jsonl.ts (2)
402-402: LGTM! Simplified error handling.Removing the custom
StreamInterruptedErrortype in favor of standard error handling improves code maintainability.
451-471: LGTM! Improved error handling and cleanup.The changes enhance the stream controller by:
- Adding proper error propagation
- Implementing thorough cleanup
- Following best practices for resource management
packages/server/src/unstable-core-do-not-import/stream/jsonl.test.ts (2)
212-213: LGTM! Consistent error message formatting.The error message format follows the standard pattern.
557-557: LGTM! Proper error type expectation.Using
DOMExceptionfor abort errors aligns with web standards.packages/tests/server/streaming.test.ts (1)
356-360: LGTM! Standardized abort error messages.The error messages now correctly reflect the abort operation using standard web platform error messages.
lucacasonato
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works. Using AbortError here makes sense to me.
|
This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you. |
Closes #6461
🎯 Changes
✅ Checklist
Summary by CodeRabbit