-
Notifications
You must be signed in to change notification settings - Fork 131
chore(rivetkit): add listing actors by only name to manager api #3430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
More templates
@rivetkit/actor
@rivetkit/cloudflare-workers
@rivetkit/core
@rivetkit/db
@rivetkit/framework-base
@rivetkit/next-js
@rivetkit/react
rivetkit
@rivetkit/sql-loader
@rivetkit/engine-runner
@rivetkit/engine-runner-protocol
commit: |
Code ReviewThank you for this PR! I've reviewed the changes adding the ✅ Positive Aspects
🔍 Issues & Concerns1. Missing Test Coverage (High Priority)The PR adds a new API endpoint but doesn't include any tests. According to CLAUDE.md guidelines, tests should be added. Please add:
2. Incomplete Cloudflare Workers Implementation (Medium Priority)
The Cloudflare Workers driver returns an empty array with just a warning. This could silently fail in production: async listActors({ c, name }: ListActorsInput): Promise<ActorOutput[]> {
logger().warn({
msg: "listActors not fully implemented for Cloudflare Workers",
name,
});
return [];
}Recommendation: Either implement this properly using KV list operations or throw an throw new Unsupported("listActors");3. Unused Parameters in ListActorsInput (Low Priority)
The export interface ListActorsInput<E extends Env = any> {
c?: HonoContext | undefined;
name: string;
key?: string; // Not used anywhere
includeDestroyed?: boolean; // Not used anywhere
}Recommendation: Either implement filtering by these parameters or remove them to avoid confusion. Keeping unused parameters in the interface suggests future functionality but could mislead other developers. 4. Potential Performance Issue (Medium Priority)
The const itr = this.#state.getActorsIterator({});
for await (const actor of itr) {
if (actor.name === name) {
actors.push({...});
}
}Concerns:
Recommendation:
5. Missing Optional Timestamp (Low Priority)
The export interface ActorOutput {
actorId: string;
name: string;
key: ActorKey;
createTs?: number;
}But in create_ts: actor.createTs ?? Date.now(),Recommendation: Ensure all drivers consistently populate 6. Inconsistent Error Handling (Low Priority)The validation logic in Recommendation: Add code comments documenting the three supported query patterns:
📝 Minor Suggestions
🔒 SecurityNo security concerns identified. The implementation properly validates inputs and doesn't introduce any obvious vulnerabilities. 🎯 SummaryThis is a solid foundation for the
The code quality is good and follows the project conventions. Once the test coverage is added and the performance/pagination concerns are addressed, this will be ready to merge. Would you like me to help write tests for this functionality? |
02250ac to
51507e2
Compare
8fdd032 to
14348ed
Compare
PR Review: Add listing actors by only name to manager APIOverviewThis PR adds a new listActors method to the manager driver interface that allows listing all actors by name, without requiring a specific key. This is a useful addition for querying actors when you know the actor type but not the specific key. Code Quality - PositiveStrengths:
Issues Found1. Inconsistent parameter usage in ListActorsInput (router.ts:364-369)
2. Logging inconsistency (cloudflare-workers/src/manager-driver.ts:352-358)
3. Performance issue in FileSystemManagerDriver (drivers/file-system/manager.ts:337-345)
4. No test coverage - CRITICAL
5. Cloudflare Workers implementation returns empty array
6. Missing pagination
7. createTs is optional (manager/driver.ts:107)
8. Unused key parameter in router.ts (line 367)
Security Considerations
SummaryOverall Assessment: This is a solid addition that extends the manager API in a useful way. The implementation is clean and follows existing patterns. Must Address:
Should Address:
Great work overall! With test coverage and the pagination/parameter cleanup, this will be a solid feature. |
Code Review for PR #3430OverviewThis PR adds the ability to list actors by name only through the manager API. The implementation looks solid overall, but I've identified several areas that could benefit from improvements. Critical Issues1. Missing Implementation in Cloudflare Workers DriverLocation: rivetkit-typescript/packages/cloudflare-workers/src/manager-driver.ts:352-358 The Cloudflare Workers implementation returns an empty array with a warning. This creates an inconsistent API experience across different drivers. Recommendation: Consider whether this functionality can be implemented using KV storage patterns similar to other methods in this driver, or if not possible, document this limitation clearly in the driver's interface or throw an explicit not implemented error rather than silently returning empty results. Performance Concerns2. Inefficient Full Table Scan in FileSystem DriverLocation: rivetkit-typescript/packages/rivetkit/src/drivers/file-system/manager.ts:337-359 This performs a full table scan filtering by name in memory. For large actor counts, this could become a performance bottleneck. Recommendations:
Design and API Issues3. Unused Parameters in ListActorsInputLocation: rivetkit-typescript/packages/rivetkit/src/manager/driver.ts:96-101 The key and includeDestroyed parameters are defined but never used in any implementation. Either implement these parameters or remove them from the interface. Unused parameters create confusion about API capabilities. 4. Inconsistent Optional createTs FieldLocation: rivetkit-typescript/packages/rivetkit/src/manager/driver.ts:103-108 The createTs field is optional, but it's always populated in the FileSystem driver implementation and used in sorting. Either make this field required (preferred) or document when it may be undefined and ensure all code paths handle the undefined case correctly. Code Quality Issues5. Type Casting in FileSystem DriverLocation: rivetkit-typescript/packages/rivetkit/src/drivers/file-system/manager.ts:346 Using actor.key as string[] bypasses TypeScript's type safety. If actor.key is not actually a string[], this could cause runtime errors. Verify the actual type and either fix the type definition or add runtime validation. 6. Inconsistent Error MessagesLocation: rivetkit-typescript/packages/rivetkit/src/manager/router.ts:282,292,357 The error messages have inconsistent styles. Standardize error message format for better developer experience. Missing Test Coverage7. No Tests for New FunctionalityNo test files were modified or added for the new listActors functionality. Recommendation: Add tests covering:
Consider adding tests in the driver test suite at rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/ Security and Documentation8. Consider Rate Limiting and PaginationThe listActors endpoint could return large result sets, which might consume excessive memory, create performance issues, or enable DoS vectors. Add pagination support (limit/offset or cursor-based) to the API. 9. Missing API DocumentationThe new endpoint and driver method lack documentation comments explaining what actors are returned, sort order, parameter meanings, and return value constraints. SummaryStrengths:
Required Changes:
Recommended Changes: Overall, this is a solid foundation for listing actors by name, but needs test coverage and consideration of the performance implications at scale. |
51507e2 to
a8f3a9c
Compare
Code Review: Add listing actors by name to manager APISummaryThis PR adds a new Issues and Concerns1. Missing Implementation of
|
Merge activity
|

No description provided.