-
Notifications
You must be signed in to change notification settings - Fork 44
fix(core): clean up websocket protocol handling #1297
fix(core): clean up websocket protocol handling #1297
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @NathanFlurry's task —— View job PR Review: fix(core): fix websocket protocol for rivetkitI've completed a comprehensive review of this pull request. Here's my analysis: Review Progress:
🔍 SummaryThis PR fixes the WebSocket protocol handling in RivetKit by migrating from HTTP headers to WebSocket subprotocols for passing connection parameters. The changes span across multiple components including the Cloudflare Workers adapter, core router, and engine driver. ✅ Positive Changes
|
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
More templates
@rivetkit/actor
@rivetkit/cloudflare-workers
@rivetkit/core
@rivetkit/db
@rivetkit/framework-base
@rivetkit/next-js
@rivetkit/react
rivetkit
@rivetkit/sql-loader
commit: |
d7f6752 to
ab42017
Compare
c87f833 to
e972ad5
Compare
|
Claude finished @NathanFlurry's task —— View job PR Review: fix(core): fix websocket protocol for rivetkitI'll provide a comprehensive review focusing on code quality, bugs, performance, security, and test coverage. Review Progress:
🔍 SummaryThis PR fixes WebSocket protocol handling by migrating from HTTP headers to WebSocket subprotocols for passing connection parameters. The changes span across multiple components including the Cloudflare Workers adapter, core router, and engine driver. ✅ Positive Changes
|
|
Claude finished @NathanFlurry's task —— View job PR Review: WebSocket Protocol FixReview Progress:
🔧 SummaryThis PR fixes WebSocket protocol handling in RivetKit by migrating from HTTP headers to WebSocket subprotocols for passing connection parameters. The changes address proper parsing of comma-separated protocol lists and create architectural consistency across all components. ✅ Positive Changes1. Critical Protocol Parsing Bug FixFixed in
This prevents false positives where a protocol containing the target protocol as a substring would incorrectly match. 2. Architectural ConsistencyAll three components now consistently parse WebSocket subprotocols instead of headers:
3. Proper Error HandlingThe router correctly handles JSON parsing with appropriate error handling (though this appears to be outside the scope of current changes).
|
ab42017 to
897b60a
Compare
e972ad5 to
35b80aa
Compare
|
Claude finished @NathanFlurry's task —— View job PR Review: WebSocket Protocol FixI've completed a thorough review of this pull request that fixes WebSocket protocol handling by migrating from HTTP headers to WebSocket subprotocols. Here's my comprehensive analysis: Review Progress:
🔍 SummaryThis PR fixes the WebSocket protocol handling in RivetKit by migrating from HTTP headers to WebSocket subprotocols for passing connection parameters. The changes span across multiple components including the Cloudflare Workers adapter, core router, and engine driver. ✅ What's Good
🚨 Critical Issues1. Missing Error Handling for JSON ParsingLocations:
Issue: Impact: Malformed JSON in connection parameters will crash the WebSocket connection. Fix Required: const connParams = connParamsRaw ? (() => {
try {
return JSON.parse(connParamsRaw);
} catch (e) {
logger().warn("invalid connection parameters", { connParamsRaw, error: e });
return undefined;
}
})() : undefined;2. Bug in Engine DriverLocation: Issue: There are two identical variable declarations for const protocols = request.headers.get("sec-websocket-protocol");
if (protocols === null)
throw new Error(`Missing sec-websocket-protocol header`);
// Parse configuration from Sec-WebSocket-Protocol header
const protocols = request.headers.get("sec-websocket-protocol"); // ← Duplicate!Fix: Remove the duplicate line 312.
|
|
Claude finished @NathanFlurry's task —— View job PR Review: WebSocket Protocol FixI've completed a comprehensive review of this pull request. Here's my analysis: Review Progress:
🔍 SummaryThis PR fixes the WebSocket protocol handling in RivetKit by migrating from HTTP headers to WebSocket subprotocols for passing connection parameters. The changes span across the Cloudflare Workers adapter ( ✅ Positive Changes
|
35b80aa to
9529818
Compare
|
Claude finished @NathanFlurry's task —— View job PR Review: WebSocket Protocol FixI've completed a comprehensive review of this pull request that fixes WebSocket protocol handling by migrating from HTTP headers to WebSocket subprotocols. Here's my detailed analysis: Review Progress:
🔍 SummaryThis PR fixes the WebSocket protocol handling in RivetKit by migrating from HTTP headers to WebSocket subprotocols for passing connection parameters. The changes span across multiple components including the Cloudflare Workers adapter, core router, and engine driver. ✅ Positive Changes
|
897b60a to
72edb6d
Compare
9529818 to
3586c3d
Compare
|
Claude finished @NathanFlurry's task —— View job PR Review: WebSocket Protocol FixI've completed a comprehensive review of this WebSocket protocol handling fix, focusing on code quality, bugs, performance, security, and test coverage. Review Progress:
🔍 SummaryThis PR fixes the WebSocket protocol handling in RivetKit by migrating from HTTP headers to WebSocket subprotocols for passing connection parameters. The changes span across multiple components including the Cloudflare Workers adapter ( ✅ Positive Changes
🚨 Critical Issues1. Missing Error Handling for JSON ParsingLocations:
Issue: Impact: Malformed JSON in connection parameters will crash the WebSocket connection. Fix Required: const connParams = connParamsRaw ? (() => {
try {
return JSON.parse(connParamsRaw);
} catch (e) {
logger().warn("invalid connection parameters", { connParamsRaw, error: e });
return undefined;
}
})() : undefined;2. Bug in Engine DriverLocation: Issue: There are two identical variable declarations for const protocols = request.headers.get("sec-websocket-protocol");
if (protocols === null)
throw new Error(`Missing sec-websocket-protocol header`);
// Parse configuration from Sec-WebSocket-Protocol header
const protocols = request.headers.get("sec-websocket-protocol"); // ← Duplicate!Fix: Remove the duplicate line 312. 🔒 Security & Quality Concerns3. Protocol Injection VulnerabilityLocations: All protocol parsing loops Issue: No validation of protocol format before processing. Risk: Malicious clients could send malformed protocols. Recommendation: Add basic validation: if (protocol.includes('.') && protocol.indexOf('.') > 0) {
// Process protocol
}4. Code DuplicationIssue: Nearly identical protocol parsing logic exists in three files with slight variations. This violates DRY principles. Recommendation: Extract to shared utility function: // In common/websocket-protocol-parser.ts
export function parseWebSocketProtocols(protocols: string | null) {
// Shared parsing logic
}5. Unused VariablesLocations:
Issue: Variables are parsed but never used, suggesting incomplete implementation or dead code. 🧪 Test Coverage AnalysisCurrent State:
Gaps:
Recommendation: Add tests for: test("should handle malformed WebSocket protocols gracefully", () => {
// Test invalid protocol formats
// Test malformed JSON in connection parameters
// Test protocol injection attempts
});🏎️ Performance ConsiderationsMinor Issues:
Impact: Low - only affects WebSocket connection establishment, not message throughput. 📋 Dependency AnalysisChanges in
📊 Overall AssessmentSeverity Breakdown:
🎯 RecommendationsMust Fix Before Merge:
Should Fix Soon: Nice to Have: Verdict: |
|
Claude finished @NathanFlurry's task —— View job PR Review: WebSocket Protocol FixI've completed a comprehensive review of this pull request that fixes WebSocket protocol handling by migrating from HTTP headers to WebSocket subprotocols. Here's my detailed analysis: Review Progress:
🔍 SummaryThis PR fixes the WebSocket protocol handling in RivetKit by migrating from HTTP headers to WebSocket subprotocols for passing connection parameters. The changes span across the Cloudflare Workers adapter ( ✅ Positive Changes
|
Merge activity
|

No description provided.