Skip to content

Conversation

@NathanFlurry
Copy link
Member

No description provided.

@vercel
Copy link

vercel bot commented Nov 24, 2025

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

Project Deployment Preview Comments Updated (UTC)
rivet-site Ready Ready Preview Comment Dec 1, 2025 6:01am
rivetkit-serverless Ready Ready Preview Comment Dec 1, 2025 6:01am
2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
rivet-cloud Ignored Ignored Dec 1, 2025 6:01am
rivet-inspector Ignored Ignored Preview Dec 1, 2025 6:01am

@vercel vercel bot temporarily deployed to Preview – rivetkit-serverless November 24, 2025 19:46 Inactive
Copy link
Member Author

NathanFlurry commented Nov 24, 2025


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.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 24, 2025

More templates

@rivetkit/cloudflare-workers

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

@rivetkit/db

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

@rivetkit/framework-base

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

@rivetkit/next-js

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

@rivetkit/react

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

rivetkit

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

@rivetkit/sql-loader

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

@rivetkit/engine-runner

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

@rivetkit/engine-runner-protocol

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

commit: 1724b94

@claude
Copy link

claude bot commented Nov 24, 2025

PR Review: Documentation Content Cleanup

This PR makes significant improvements to the documentation by cleaning up inconsistencies, adding clarity, and fixing several issues. Overall, this is excellent work that will improve the developer experience.

✅ Strengths

  1. Improved Code Examples: The additions to connections.mdx now include proper TypeScript interfaces and type annotations
  2. Better Cross-Referencing: Added helpful links to Events docs, WebSocket handler docs, etc.
  3. Clarifications on Lifecycle Hooks: Now clearly distinguishes between onCreate vs onWake
  4. React/useActor Documentation: Added important notes about useActor not supporting certain methods with workarounds
  5. Consolidated Design Patterns: Excellent move consolidating scaling and state sharing docs

🔍 Issues Found

1. Code Example Issues in connections.mdx

Line 145-148: The lifecycle sequence incorrectly shows createState under "On Connect". createState is only called during "On Create" (first time). The connection lifecycle should only list: onBeforeConnect, createConnState, and onConnect.

Line 28-50: References to undefined functions validateToken() and getUserIdFromToken(). Consider adding comments to indicate these are user-defined.

2. Code Issue in external-sql.mdx

Lines 66 and 183: Both examples use onCreate with parameter named opts but never use it. Should be input to match the pattern.

onStateChange pattern: This hook fires on EVERY state change, so updating requestCount triggers a database write. This could cause excessive writes. Consider adding a performance note about this.

3. Minor Inconsistencies

lifecycle.mdx Line 9: Uses numbered lists for "On Create" but not other sections - consider consistency.

Duplication: Content about createConnState appears in multiple places (lines 87-109 and 260-267).

📝 Suggestions

  1. Add warning about onStateChange write amplification in SQL examples
  2. Consider showing how to use runInBackground for database syncs to avoid blocking
  3. Verify all cross-reference links are valid

🔒 Security

✅ Good: Examples properly demonstrate authentication validation
✅ Good: Parameterized queries used correctly

🎯 Performance

✅ Connection pooling implemented correctly
⚠️ onStateChange pattern needs performance caveat

✨ Overall Assessment

High-quality documentation work that significantly improves clarity. Main issues are minor code example inconsistencies and potential performance pitfalls that should be documented.

Recommendation: Approve with minor revisions to fix the technical inaccuracies noted above.

Great work! 🚀

@claude
Copy link

claude bot commented Nov 25, 2025

PR Review: Documentation Clean Up

Summary

This PR significantly improves the Rivet Actors documentation by filling in missing content, fixing typos, adding comprehensive examples, and improving overall organization. The changes enhance clarity and provide better guidance for developers working with Rivet Actors.

✅ Strengths

1. Excellent Content Additions

  • errors.mdx: Added comprehensive error handling documentation (from 1 line to 336 lines!)

    • Clear examples of UserError usage with codes and metadata
    • Security-focused approach with internal error handling
    • Great coverage of both connection and stateless patterns
  • connections.mdx: Added detailed lifecycle documentation

    • Clear explanation of connection hooks (onBeforeConnect, createConnState, onConnect, onDisconnect)
    • Practical examples for each lifecycle event
    • Good coverage of connection management patterns
  • design-patterns.mdx: Enhanced with better examples

    • Added comprehensive external database/API integration patterns
    • New onStateChange example showing state syncing
    • Improved clarity on coordinator/sharding patterns

2. Code Quality Improvements

  • Fixed typo: RequestHandlerNotDfeinedRequestHandlerNotDefined (rivetkit-typescript)
  • Consistent import statements in all examples
  • Proper TypeScript typing throughout examples
  • Good use of both tabs for actor/client perspectives

3. Proper Conventions

  • Added CLAUDE.md rule about capitalizing "Rivet Actors" as proper noun ✅
  • API Reference links added throughout documentation
  • Consistent code formatting and structure

🔍 Issues Found

Critical: Typo in CORS Documentation

File: website/src/content/docs/general/cors.mdx:64

- See tracking issue for [configuring CORS per-actor on the gateway](https://github.com/rivet-dev/rivet/issues/3539) that will remove the need to implement origin restrictions in `onBforeRequest`.
+ See tracking issue for [configuring CORS per-actor on the gateway](https://github.com/rivet-dev/rivet/issues/3539) that will remove the need to implement origin restrictions in `onBeforeConnect`.

Issue: onBforeRequest should be onBeforeConnect (missing 'e' and wrong hook name)

Minor: Potential Logic Issue in Rate Limiter Example

File: website/src/content/docs/actors/errors.mdx:172-189

The rate limiter example has a potential issue - it never resets the counter:

const api = actor({
  state: { requestCount: 0, lastReset: Date.now() },
  actions: {
    makeRequest: (c) => {
      c.state.requestCount++;
      
      const limit = 100;
      if (c.state.requestCount > limit) {
        const resetAt = c.state.lastReset + 60_000; // Reset after 1 minute
        
        throw new UserError("Rate limit exceeded", {
          code: "rate_limited",
          metadata: {
            limit: limit,
            resetAt: resetAt,
            retryAfter: Math.ceil((resetAt - Date.now()) / 1000)
          }
        });
      }
      // Rest of request logic...
    }
  }
});

Issue: The requestCount is never reset, so once it exceeds 100, it stays exceeded forever. Should include logic to reset the counter after the time window.

Suggestion:

makeRequest: (c) => {
  // Reset counter if time window has passed
  if (Date.now() - c.state.lastReset > 60_000) {
    c.state.requestCount = 0;
    c.state.lastReset = Date.now();
  }
  
  c.state.requestCount++;
  
  const limit = 100;
  if (c.state.requestCount > limit) {
    const resetAt = c.state.lastReset + 60_000;
    throw new UserError("Rate limit exceeded", {
      code: "rate_limited",
      metadata: {
        limit: limit,
        resetAt: resetAt,
        retryAfter: Math.ceil((resetAt - Date.now()) / 1000)
      }
    });
  }
}

Minor: Inconsistent Example in connections.mdx

File: website/src/content/docs/actors/connections.mdx:41-51

The createConnState example shows synchronous code but the documentation states it "Can be async":

createConnState: (c, params: ConnParams): ConnState => {
  // Validate authentication token
  const authToken = params.authToken;

  if (!authToken || !validateToken(authToken)) {
    throw new Error("Invalid auth token");
  }

  // Create connection state
  return { userId: getUserIdFromToken(authToken), role: "player" };
},

Issue: The functions validateToken and getUserIdFromToken are not defined. For a complete example, either:

  1. Show these as simple inline implementations, or
  2. Add a comment indicating they're placeholder functions

💡 Suggestions

1. Add Missing Type Exports in Examples

Some examples reference registry but don't show the setup import:

import { actor, setup } from "rivetkit"; // Add 'setup' to imports

This is inconsistent across files - some have it, some don't.

2. Consider Adding a Security Note to CORS

The CORS documentation could benefit from emphasizing that origin validation is security-critical:

<Warning>
Always implement origin restrictions for publicly exposed actors. Without origin validation, any website can connect to your actors and potentially abuse resources or access sensitive data.
</Warning>

3. Example Database Objects

The design patterns examples reference db.users but don't show how to set it up. Consider adding a note like:

// Note: 'db' represents your database client (e.g., Prisma, Drizzle, or raw SQL)
// This is just an example - implement according to your database setup

📊 Statistics

  • Files changed: 35
  • Additions: +966 lines
  • Deletions: -650 lines
  • Net change: +316 lines of improved documentation

✅ Test Coverage

This PR is documentation-only with one small code fix (typo correction). The typo fix in rivetkit-typescript is straightforward and correct.

Recommendation: Consider adding a quick smoke test to verify the documentation examples compile correctly if you have such infrastructure.

🎯 Final Verdict

Status: ✅ Approve with Minor Fixes Required

This is an excellent documentation improvement PR that significantly enhances the developer experience. The issues found are minor and easily fixable:

  1. Must fix: Typo in cors.mdx (onBforeRequestonBeforeConnect)
  2. Should fix: Rate limiter logic to actually reset the counter
  3. Nice to have: Add helper function placeholders or comments in examples

The documentation is well-structured, comprehensive, and follows proper conventions. Great work! 🎉


Reviewed by Claude Code

@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 1, 2025

Merge activity

  • Dec 1, 5:58 AM UTC: NathanFlurry added this pull request to the Graphite merge queue.
  • Dec 1, 5:59 AM UTC: CI is running for this pull request on a draft pull request (#3559) due to your merge queue CI optimization settings.
  • Dec 1, 5:59 AM UTC: Merged by the Graphite merge queue via draft PR: #3559.

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