Skip to content

Conversation

@NathanFlurry
Copy link
Member

No description provided.

@vercel
Copy link

vercel bot commented Nov 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
rivetkit-serverless Ready Ready Preview Comment Nov 10, 2025 11:33pm
3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
rivet-cloud Ignored Ignored Nov 10, 2025 11:33pm
rivet-inspector Ignored Ignored Preview Nov 10, 2025 11:33pm
rivet-site Ignored Ignored Preview Nov 10, 2025 11:33pm

This was referenced Nov 10, 2025
Copy link
Member Author

NathanFlurry commented Nov 10, 2025

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.
Learn more


How to use the Graphite Merge Queue

Add the label merge-queue to this PR to add it to 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.

@claude
Copy link

claude bot commented Nov 10, 2025

Code Review

Summary

This PR adds support for passing connection parameters (connParams) to onRequest and onWebSocket handlers. The changes properly extract connection parameters from HTTP headers and WebSocket protocols and thread them through to the connection manager.

Positive Aspects ✅

  1. Consistent Implementation: The changes follow the existing pattern used in handleWebSocketConnect and properly reuse the getRequestConnParams and parseWebSocketProtocols utility functions.

  2. Correct Parameter Threading: The connParams are properly passed through all the call sites:

    • handleRawRequest in router-endpoints.ts:344
    • handleRawWebSocket in router-endpoints.ts:373
    • Engine driver in actor-driver.ts:565
    • File system manager in manager.ts:192, 250
  3. Backwards Compatibility: The fallback to empty object for WebSocket (connParams ?? {}) ensures backwards compatibility if connParams is undefined.

  4. Good Logging: Added debug logging for connParams in the raw WebSocket handler (router.ts:190) which will help with debugging.

Issues & Concerns 🔍

1. Type Safety - Critical

The connParams parameter in handleRawWebSocket is typed as unknown | undefined:

connParams: unknown | undefined,

However, when calling prepareAndConnectConn, you are passing connParams ?? {}. This could lead to type mismatches since the connection manager expects a specific type CP (the connection parameters generic type).

Recommendation: Consider validating/parsing connParams before passing to prepareAndConnectConn, similar to how encoding is validated with EncodingSchema.parse().

2. Null vs Undefined Inconsistency - Medium

In getRequestConnParams (router-endpoints.ts:550), the function returns null when the header is not present, but the calling code in handleRawRequest assigns it to parameters without checking for null:

const parameters = getRequestConnParams(c.req); // Could be null
// ...
parameters, // Passed directly to prepareAndConnectConn

Meanwhile, for WebSocket you handle undefined with ??. This inconsistency could cause issues.

Recommendation: Make the return types consistent - either use null, undefined, or {} as the default consistently across both HTTP and WebSocket paths.

3. Missing Comment Removal - Minor

In router.ts:113, a comment was removed:

-// Parse configuration from Sec-WebSocket-Protocol header
 const protocols = c.req.header("sec-websocket-protocol");

While the comment might have been redundant, it is worth noting this was the only comment removal in the PR. Not a functional issue, but worth confirming it was intentional.

Testing Concerns 🧪

Missing Test Coverage: There do not appear to be tests added for this new functionality. Consider adding tests for:

  • onRequest handler receiving connParams via HTTP headers
  • onWebSocket handler receiving connParams via WebSocket protocols
  • Edge cases: malformed JSON in headers/protocols, missing headers, etc.

Given that this touches connection management which is critical infrastructure, test coverage would be valuable.

Performance Considerations ⚡

No performance concerns identified. The changes are minimal and follow existing patterns.

Security Considerations 🔒

Input Validation: The connParams are parsed from user-controlled input (HTTP headers or WebSocket protocols). Current implementation:

  • Uses JSON.parse() with try/catch
  • Throws InvalidParams error on parse failure

This is reasonable, but consider:

  • Adding schema validation if connParams has a specific expected structure
  • Documenting any limits on the size of connParams to prevent DoS via oversized headers

Recommendations Summary

  1. High Priority: Add type validation/parsing for connParams before passing to prepareAndConnectConn
  2. Medium Priority: Fix null/undefined inconsistency between HTTP and WebSocket paths
  3. Medium Priority: Add test coverage for the new functionality
  4. Low Priority: Consider schema validation for connParams structure

Conclusion

The implementation is solid and follows existing patterns well. The main concerns are around type safety and test coverage. With the recommendations addressed, this would be ready to merge.


🤖 Generated with Claude Code

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 10, 2025

More templates

@rivetkit/actor

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/actor@3445

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/cloudflare-workers@3445

@rivetkit/core

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/core@3445

@rivetkit/db

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/db@3445

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/framework-base@3445

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/next-js@3445

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/react@3445

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivet/rivetkit@3445

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sql-loader@3445

@rivetkit/engine-runner

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner@3445

@rivetkit/engine-runner-protocol

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner-protocol@3445

commit: 633481b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants