| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…l continuation - Abort upstream Copilot requests when the client disconnects during streaming - Configure undici connection pool (16 connections per origin) - Skip debug JSON serialization unless debug logging is enabled - Append a 'Continue.' user message when the conversation ends with an assistant turn Co-Authored-By: Claude <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. WalkthroughDirect connections use a shared agent configuration when environment proxying is disabled. The chat-completions and messages handlers select streaming or non-streaming behavior from the request setting, pass abort signals for streamed requests, and gate debug logs by log level. Message translation appends a user message containing "Continue." for qualifying assistant-ending conversations. Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to 1d2bc Streaming requests that fail upstream, such as those rejected for a missing token or by Copilot, now return a successful streaming response that contains an error event instead of a proper HTTP error. Clients that rely on status codes may misreport or retry incorrectly. Move the upstream call before the stream starts before merging. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to 1d2bc Streaming cancellation improves normal request cleanup, but failed upstream requests bypass the existing error-body cleanup path. This creates an availability risk for the shared connection pool. Server-configured credentials, destinations, and explicit proxy selection remain preserved. Retained concerns
Security Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
❌ Failed checks (1 warning)
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.
Actionable comments posted: 1
Reviewing files that changed from the base of the PR and between 0ea08fe and 1d2bc7d.
📒 Files selected for processing (8)Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📜 Review details 🔇 Additional comments (6)src/lib/proxy.ts (1)src/start.ts (1)5-21: LGTM!
Also applies to: 27-27
src/routes/messages/non-stream-translation.ts (1)10-10: LGTM!
Also applies to: 33-34
tests/anthropic-request.test.ts (1)71-78: LGTM!
src/services/copilot/create-chat-completions.ts (1)157-161: LGTM!
Also applies to: 163-182
tests/create-chat-completions.test.ts (1)3-3: LGTM!
Also applies to: 11-11, 33-33, 37-43, 51-51
58-69: LGTM!
Sorry, something went wrong.
| controller.abort() | ||
| }) | ||
|
|
||
| const response = await createChatCompletions(payload, controller.signal) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Resolve upstream failures before returning an SSE response. Both routes now await the Copilot request inside the streamSSE callback. If the token is missing or Copilot rejects the request, Hono has already returned the SSE response. Hono then writes an error event instead of allowing an HTTP error response. (github.com)
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
This PR fixes three problems in how the proxy handles requests to Copilot, and adds one small performance change.
1. Upstream requests are aborted when the client disconnects
Problem: If a client cancelled a streaming request (for example, pressed Esc in Claude Code), the proxy kept reading the Copilot stream until it finished. That wasted quota and kept connections open.
Fix:
2. HTTP connection pooling (Node only)
Problem: The default undici Agent was used without explicit limits.
Fix: Added initDirectConnectionPool(), which sets a global undici Agent with 16 connections per origin and pipelining: 1. It runs when --proxy-env is not set. The direct agent inside initProxyFromEnv uses the same settings. This is skipped under Bun, as before.
3. Assistant prefill / conversations that end on an assistant turn
Problem: Anthropic clients can send a conversation whose last message is from the assistant (a "prefill"). Copilot's OpenAI-style endpoint does not handle that, so the request either fails or returns an empty or unexpected completion.
Fix: When the translated conversation ends with an assistant message that has no tool calls, a { role: "user", content: "Continue." } message is added at the end.
4. Debug logging is cheaper
JSON.stringify of payloads, chunks, and responses now runs only when consola.level >= 4 (debug). Before this, every streamed chunk was serialized even when debug logging was off.
Testing
Notes
🤖 Generated with Claude Code