fix: abort cancelled answer streams#757
Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Warning Review limit reached
Next review available in: 34 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAnswer streaming now propagates both request and reader cancellation through a unified abort signal, suppresses cancellation SSE errors, and cleans up listeners. Tests inject answer behavior to verify abort propagation, while the review ledger records completed reviews. ChangesAnswer stream cancellation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant ReadableStream
participant streamAnswer
participant answerQuestionWithScope
Client->>ReadableStream: cancel response reader
ReadableStream->>streamAnswer: cancel(reason)
streamAnswer->>answerQuestionWithScope: abort unified streamSignal
answerQuestionWithScope-->>streamAnswer: stop generation
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@copilot resolve the merge conflicts in this pull request |
…ue-api-route-family # Conflicts: # docs/branch-review-ledger.md
Head branch was pushed to by a user without write access
Resolved. The only conflict was in |
Motivation
Requestsignal, allowing a ReadableStream consumer cancel to leave expensive work running and to produce stale SSE error frames.Description
signalto bothsummarizeDocumentandanswerQuestionWithScopeso retrieval/generation stop when the client cancels. (editedsrc/app/api/answer/stream/route.ts)errorframes when the combined signal is aborted so a cancelled consumer does not see duplicate or misleading errors; keep existing SSE error payloads for genuine server faults. (editedsrc/app/api/answer/stream/route.ts)ReadableStream.cancelhandler that aborts the same controller, and tidy the request-abort listener lifecycle to avoid leaks. (editedsrc/app/api/answer/stream/route.ts)tests/private-rag-access.test.ts)docs/branch-review-ledger.md)Testing
git diff --check/ workspace static checks passed before and after the change. (OK)npm run eval:rag:offlineand passed the golden fixtures (36 cases, 21 suites); the test harness could not proceed to the local Vitest stage becausenode_modules/vitestis not present in this worktree. (partial pass)verify:cheapwere not executed because the environment lacks local dev dependencies (vitest,tsx), so lint/typecheck/unit/build gates were selected by averify:pr-local -- --dry-runbut not run for real. (blocked by missing node_modules)codex/harden-answer-streamingand the repository ledger was updated to record the review outcome; the environment had no configured remote so pushing/hosted-PR creation was not performed from this session. (local branch contains the edits)Files changed:
Notes: provider-backed checks (
check:production-readiness, live retrieval/answer evals) were not run because they require explicit approval and live keys; no external services were called or mutated during this work.Codex Task
Summary by CodeRabbit