Skip to content

Conversation

@NathanFlurry
Copy link
Member

No description provided.

@vercel
Copy link

vercel bot commented Nov 9, 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 13, 2025 8:55pm
3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
rivet-cloud Ignored Ignored Nov 13, 2025 8:55pm
rivet-inspector Ignored Ignored Preview Nov 13, 2025 8:55pm
rivet-site Ignored Ignored Preview Nov 13, 2025 8:55pm

Copy link
Member Author

NathanFlurry commented Nov 9, 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 9, 2025

PR Review: Add connection for raw HTTP

Summary

This PR adds a new createRawHttpSocket() connection driver and handleRawHttpHandler() function to properly track HTTP request lifecycle through the actor's connection management system. Overall, the implementation is well-structured and follows existing patterns in the codebase.

Code Quality & Best Practices

✅ Good Practices:

  • Follows existing driver patterns (consistent with createHttpSocket() and createRawWebSocketSocket())
  • Clear documentation explaining the purpose and difference from standard HTTP driver
  • Proper cleanup of connections in finally block
  • Consistent code style and formatting

⚠️ Issues & Recommendations:

1. Connection Lifecycle Inconsistency (rivetkit-typescript/packages/rivetkit/src/actor/router-endpoints.ts:548-572)

Issue: The signature of getConnectionReadyState is inconsistent with the interface definition.

In createRawHttpSocket():

getConnectionReadyState: (): DriverReadyState | undefined => {
    // HTTP connections are always considered open until the request completes
    return DriverReadyState.OPEN;
},

But the ConnDriver interface expects:

getConnectionReadyState(
    actor: AnyActorInstance,
    conn: AnyConn,
): DriverReadyState | undefined;

Fix: Update the signature to match the interface:

getConnectionReadyState: (_actor, _conn): DriverReadyState | undefined => {
    return DriverReadyState.OPEN;
},

This matches the pattern used in createHttpSocket() at rivetkit-typescript/packages/rivetkit/src/actor/conn/drivers/http.ts:10.

2. Disconnect Signature Inconsistency (rivetkit-typescript/packages/rivetkit/src/actor/conn/drivers/raw-http.ts:16-18)

Issue: The disconnect method signature doesn't match the ConnDriver interface.

Current implementation:

disconnect: async () => {
    // Noop
},

Expected signature from interface:

disconnect(
    actor: AnyActorInstance,
    conn: AnyConn,
    reason?: string,
): Promise<void>;

Fix: Update to match interface:

disconnect: async (_actor, _conn, _reason?) => {
    // Noop
},

3. Missing Error Handling Context (rivetkit-typescript/packages/rivetkit/src/actor/router-endpoints.ts:560-571)

Issue: If actor.createConn() throws an error, the connection cleanup logic in the finally block won't execute properly since createdConn will be undefined.

Current code:

try {
    const conn = await actor.createConn(createRawHttpSocket(), {}, req);
    createdConn = conn;
    return await actor.handleRawRequest(req, {});
} finally {
    if (createdConn) {
        actor.connDisconnected(createdConn, true);
    }
}

Recommendation: This is actually correct as-is - if createConn throws, we don't want to clean up a connection that was never created. However, consider adding error logging for clarity:

try {
    const conn = await actor.createConn(createRawHttpSocket(), {}, req);
    createdConn = conn;
    return await actor.handleRawRequest(req, {});
} catch (error) {
    // Connection creation or request handling failed
    // Only clean up if connection was successfully created
    throw error;
} finally {
    if (createdConn) {
        actor.connDisconnected(createdConn, true);
    }
}

Performance Considerations

✅ Good:

  • No performance concerns identified
  • Proper cleanup ensures connections don't leak
  • Consistent with existing HTTP driver patterns

Security Concerns

No major security issues identified. The implementation properly:

  • Handles request cleanup
  • Doesn't expose sensitive data
  • Follows existing security patterns

Test Coverage

⚠️ Missing:

  • No tests included for the new handleRawHttpHandler() function
  • No tests verifying connection lifecycle for raw HTTP requests
  • No tests verifying cleanup happens in error cases

Recommendation: Add tests to verify:

  1. Connection is created when handling raw HTTP requests
  2. Connection is properly cleaned up after request completes
  3. Connection cleanup happens even when handleRawRequest throws
  4. The connection driver state is correct throughout the lifecycle

Additional Notes

Router path handling (rivetkit-typescript/packages/rivetkit/src/actor/router.ts:178):
The path prefix replacement logic is clean:

const originalPath = url.pathname.replace(/^\/request/, "") || "/";

This is simpler than the previous implementation and correctly handles the path stripping.

Summary

Required Changes:

  1. Fix getConnectionReadyState signature to match interface
  2. Fix disconnect signature to match interface

Recommended Changes:

  1. Add test coverage for the new functionality
  2. Consider adding error logging for better debugging

Overall, this is a solid implementation that follows existing patterns well. The required fixes are minor TypeScript signature issues that should be straightforward to address.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 9, 2025

More templates

@rivetkit/actor

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

@rivetkit/cloudflare-workers

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

@rivetkit/core

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

@rivetkit/db

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

@rivetkit/framework-base

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

@rivetkit/next-js

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

@rivetkit/react

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

rivetkit

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

@rivetkit/sql-loader

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

@rivetkit/engine-runner

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

@rivetkit/engine-runner-protocol

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

commit: 7095d1c

@NathanFlurry NathanFlurry force-pushed the 11-09-chore_rivetkit_add_connection_for_raw_http branch from 2c681e1 to d1c3287 Compare November 13, 2025 02:47
@NathanFlurry NathanFlurry force-pushed the 11-09-chore_rivetkit_rename_onfetch_to_onrequest_ branch from 5bf1455 to fc159fd Compare November 13, 2025 02:47
@claude
Copy link

claude bot commented Nov 13, 2025

Code Review: PR #3425 - Add Connection for Raw HTTP

Overview

This PR adds a new createRawHttpSocket driver for managing raw HTTP connection lifecycle tracking, and creates a dedicated handleRawHttpHandler function to properly track HTTP requests through the actor system.


✅ Positive Observations

  1. Good Pattern Consistency: The new raw-http.ts driver follows the same structure as the existing http.ts and raw-websocket.ts drivers, maintaining codebase consistency.

  2. Proper Connection Lifecycle: The PR correctly implements connection creation and cleanup with createConn and connDisconnected, which is essential for proper resource management.

  3. Documentation: The JSDoc comment in raw-http.ts clearly explains the purpose and how it differs from the standard HTTP driver.

  4. Clean Refactoring: Moving the HTTP handling logic from inline in the router to a dedicated handleRawHttpHandler function improves code organization and follows the pattern established by handleRawWebSocketHandler.


🔍 Issues & Concerns

1. Missing Connection Cleanup on Error Path ⚠️ CRITICAL

Location: rivetkit-typescript/packages/rivetkit/src/actor/router-endpoints.ts:548-572

The handleRawHttpHandler function has a potential resource leak. If actor.createConn throws an exception, the createdConn variable will remain undefined, but if it succeeds and then actor.handleRawRequest throws, the finally block will still clean up properly. However, there's a subtle issue:

try {
    const conn = await actor.createConn(createRawHttpSocket(), {}, req);
    createdConn = conn;
    return await actor.handleRawRequest(req, {});
} finally {
    if (createdConn) {
        actor.connDisconnected(createdConn, true);
    }
}

Issue: If handleRawRequest throws, the error propagates correctly, but we should verify that connDisconnected doesn't throw. If it does, the original error would be masked.

Recommendation: Consider wrapping the cleanup in a try-catch:

} finally {
    if (createdConn) {
        try {
            actor.connDisconnected(createdConn, true);
        } catch (cleanupError) {
            // Log cleanup error but don't mask the original error
            actor.rLog.error({ msg: "error during connection cleanup", error: cleanupError });
        }
    }
}

2. Inconsistent Driver Implementation

Location: rivetkit-typescript/packages/rivetkit/src/actor/conn/drivers/raw-http.ts:15-24

The getConnectionReadyState function signature differs from the interface:

getConnectionReadyState: (): DriverReadyState | undefined => {
    return DriverReadyState.OPEN;
}

But the ConnDriver interface expects:

getConnectionReadyState(
    actor: AnyActorInstance,
    conn: AnyConn,
): DriverReadyState | undefined;

Recommendation: Update to match the interface signature (even if parameters are unused):

getConnectionReadyState: (_actor, _conn): DriverReadyState | undefined => {
    return DriverReadyState.OPEN;
}

This matches the pattern used in http.ts:10.

3. Potential State Management Issue

Location: rivetkit-typescript/packages/rivetkit/src/actor/conn/drivers/raw-http.ts:12-13

requestId: crypto.randomUUID(),
requestIdBuf: undefined,

For HTTP connections, requestIdBuf is always undefined. This is consistent with http.ts, but it's worth noting that:

  • The connection is NOT hibernatable (which is correct for HTTP)
  • The requestId is randomly generated each time

Question: Should the requestIdBuf be derived from requestId for consistency? Looking at the codebase, it seems HTTP connections intentionally don't support hibernation, so this is fine. But consider adding a comment explaining why requestIdBuf is undefined.

4. Missing Error Context

Location: rivetkit-typescript/packages/rivetkit/src/actor/router-endpoints.ts:548-572

The function doesn't add any logging for connection creation/cleanup. Compare this to the WebSocket handler pattern around line 270-296 which includes detailed logging:

if (event.wasClean) {
    actor.rLog.info({
        msg: "websocket closed",
        code: event.code,
        reason: event.reason,
        wasClean: event.wasClean,
    });
}

Recommendation: Add structured logging for debugging:

export async function handleRawHttpHandler(
    req: Request,
    actorDriver: ActorDriver,
    actorId: string,
): Promise<Response> {
    const actor = await actorDriver.loadActor(actorId);
    let createdConn: AnyConn | undefined;

    try {
        actor.rLog.debug({ msg: "creating raw http connection" });
        const conn = await actor.createConn(createRawHttpSocket(), {}, req);
        createdConn = conn;

        return await actor.handleRawRequest(req, {});
    } finally {
        if (createdConn) {
            actor.rLog.debug({ msg: "cleaning up raw http connection", connId: createdConn.id });
            actor.connDisconnected(createdConn, true);
        }
    }
}

🧪 Test Coverage

Missing: There don't appear to be any tests added for the new functionality. The PR should include:

  1. Test that raw HTTP connections are properly created and cleaned up
  2. Test that the connection appears in the actor's connection list during the request
  3. Test that connections are cleaned up even when handleRawRequest throws
  4. Test that the connection lifecycle integrates correctly with the actor system

Recommendation: Look at existing tests in the test files (e.g., driver-engine.test.ts) for patterns on how to test connection lifecycle.


🔒 Security Considerations

✅ No obvious security issues. The connection tracking is internal to the actor system and doesn't expose any new attack surface.


⚡ Performance Considerations

  1. Connection Overhead: Creating a connection object for every HTTP request adds overhead. This is intentional for lifecycle tracking, but worth noting.

  2. UUID Generation: crypto.randomUUID() is called for every HTTP request. This is likely fine for most workloads, but if you're dealing with very high-frequency requests, consider if you need the full UUID entropy or if a simpler ID generation would suffice.


📝 Additional Recommendations

  1. Type Safety: Consider adding a type for the empty object literal {} used as params:

    const conn = await actor.createConn(createRawHttpSocket(), {} as Record<never, never>, req);
  2. Consistency with Actions: The handleAction function (line 319-367) also uses createHttpSocket() for HTTP-based actions. Should raw HTTP requests use a different driver than actions? If they should be tracked differently, the current approach is correct. If not, consider documenting why they differ.

  3. Path Handling: The router change at line 178 changes the path stripping from /raw/http to /request. Verify this is intentional and doesn't break existing functionality.


Summary

Verdict: ✅ Approve with minor changes recommended

The PR implements a clean solution for tracking raw HTTP connection lifecycle. The main concerns are:

  • Missing error handling in cleanup (recommended but not critical)
  • Minor signature inconsistency in the driver
  • Missing test coverage (should be addressed before merge)
  • Could benefit from structured logging

The code follows established patterns well and the architecture decision to track HTTP connections through the actor system makes sense for observability and lifecycle management.

@claude
Copy link

claude bot commented Nov 13, 2025

PR Review: Add Connection for Raw HTTP

Summary

This PR adds connection lifecycle management for raw HTTP requests by creating a createRawHttpSocket driver and handleRawHttpHandler function. This ensures HTTP requests are properly tracked through the actor's connection system, similar to how WebSocket connections are managed.


Code Quality & Best Practices ✅

Positive aspects:

  • Follows existing patterns well - mirrors the raw-websocket.ts driver structure
  • Clean separation of concerns - driver creation separate from handler logic
  • Good code comments explaining purpose and differences from standard HTTP driver
  • Consistent with TypeScript/RivetKit coding conventions

Issues & Concerns

1. Missing connection cleanup on error path ⚠️

Location: rivetkit-typescript/packages/rivetkit/src/actor/router-endpoints.ts:548-572

export async function handleRawHttpHandler(
	req: Request,
	actorDriver: ActorDriver,
	actorId: string,
): Promise<Response> {
	const actor = await actorDriver.loadActor(actorId);

	// Track connection outside of scope for cleanup
	let createdConn: AnyConn | undefined;

	try {
		const conn = await actor.createConn(createRawHttpSocket(), {}, req);

		createdConn = conn;

		return await actor.handleRawRequest(req, {});
	} finally {
		// Clean up the connection after the request completes
		if (createdConn) {
			actor.connDisconnected(createdConn, true);
		}
	}
}

Issue: If actor.createConn() throws an error, createdConn will be undefined, but a connection might have been partially created and tracked in the actor's connection manager. Looking at connection-manager.ts:267-335, the #createNewConn method adds the connection to this.#connections and this.#changedConnections before calling lifecycle hooks. If onConnect throws an error, the connection is added to the maps but never cleaned up.

Recommendation: Either:

  1. Wrap the actor.connDisconnected() call in a try-catch to handle cases where the connection doesn't exist
  2. Check if the connection was successfully added to the actor's connection map before calling connDisconnected

2. Inconsistent parameter signature 🤔

Location: rivetkit-typescript/packages/rivetkit/src/actor/conn/drivers/raw-http.ts:10-26

The createRawHttpSocket() function takes no parameters, while the similar createRawWebSocketSocket() in raw-websocket.ts:14-52 takes:

  • requestId: string
  • requestIdBuf: ArrayBuffer | undefined
  • hibernatable: boolean
  • websocket: UniversalWebSocket
  • closePromise: Promise<void>

Looking at createHttpSocket() in http.ts, it also takes no parameters and generates a random requestId. However, the inconsistency raises a question: Should raw HTTP connections support hibernation?

Context from the code:

  • From connection-manager.ts:78-91, the createConn method checks driver.requestIdBuf && driver.hibernatable to determine if a connection can be reconnected after hibernation
  • Raw HTTP connections currently set hibernatable: false and requestIdBuf: undefined
  • The handleRawHttpHandler doesn't extract rivetRequestId from the request event like handleRawWebSocketHandler does at line 398

Question: Is this intentional? HTTP requests are typically stateless and short-lived, so not supporting hibernation makes sense. However, it would be good to document this decision explicitly.

3. Missing terminate method ℹ️

Location: rivetkit-typescript/packages/rivetkit/src/actor/conn/drivers/raw-http.ts:10-26

The createRawHttpSocket driver doesn't implement the optional terminate() method from the ConnDriver interface (see driver.ts:35). While this is optional, the raw-websocket.ts driver implements it at lines 41-43:

terminate: () => {
	(websocket as any).terminate?.();
},

Recommendation: While HTTP connections don't typically need forceful termination like WebSockets, consider adding a comment explaining why terminate is not implemented, or add a no-op implementation for consistency.

4. Async return without await ⚠️

Location: rivetkit-typescript/packages/rivetkit/src/actor/conn/drivers/raw-http.ts:17-19

disconnect: async () => {
	// Noop
},

The disconnect method is marked async but doesn't await anything. While this is technically correct (returns Promise<void>), it's inconsistent with the pattern in http.ts:14-17 which is also a noop but uses the same pattern.

Recommendation: This is a minor style issue. Consider being consistent across drivers - either all use async () => {} or all use () => Promise.resolve() for no-op disconnects.


Performance Considerations ✅

Good:

  • Connection tracking overhead is minimal - just map operations
  • No unnecessary async operations
  • Proper cleanup in finally block ensures resources are released

Note: The connection lifecycle adds a small amount of overhead to each HTTP request (creating/tracking/cleaning connection objects), but this is necessary for consistency with the actor model and enabling features like connection tracking, onConnect/onDisconnect hooks, and potential future hibernation support.


Security Concerns ✅

No security issues identified. The PR doesn't introduce any new security vectors:

  • Uses existing actor authentication/authorization mechanisms
  • No user input handling changes
  • Connection cleanup prevents resource leaks

Test Coverage ✅

Looking at driver-test-suite/tests/raw-http.ts, the existing tests extensively cover raw HTTP functionality:

  • Basic GET/POST requests ✅
  • State tracking across requests ✅
  • Header handling ✅
  • Error cases (404, void return, missing handler) ✅
  • Multiple HTTP methods ✅
  • Binary data ✅
  • Hono router integration ✅

Recommendation: Consider adding a test that specifically validates connection lifecycle:

  • Verify onConnect is called when HTTP request starts
  • Verify onDisconnect is called when HTTP request completes
  • Verify connection appears in actor.connections during request
  • Verify connection is removed after request completes

This would ensure the connection tracking added by this PR works correctly.


Additional Notes

Documentation: The inline comments are good, but consider adding a note in the module documentation about when to use raw HTTP vs the standard protocol-based approach.

Consistency with router changes: The refactoring in router.ts:173-201 that extracts the HTTP handler logic to handleRawHttpHandler is a good architectural improvement - it makes the router cleaner and puts connection management logic in the endpoints file where it belongs.


Summary

This is a solid PR that properly extends the connection management system to raw HTTP requests. The main concerns are:

  1. Critical: Error handling in connection cleanup (should be addressed)
  2. Minor: Missing documentation about hibernation support decision
  3. Nice-to-have: Test coverage for connection lifecycle hooks

The code follows existing patterns well and the architectural changes improve code organization. With the error handling fix, this would be ready to merge.

@graphite-app graphite-app bot force-pushed the 11-09-chore_rivetkit_rename_onfetch_to_onrequest_ branch from fc159fd to 1109cc5 Compare November 13, 2025 20:53
@NathanFlurry NathanFlurry force-pushed the 11-09-chore_rivetkit_rename_onfetch_to_onrequest_ branch from 1109cc5 to b3ff582 Compare November 13, 2025 20:53
@NathanFlurry NathanFlurry force-pushed the 11-09-chore_rivetkit_add_connection_for_raw_http branch from d1c3287 to 7095d1c Compare November 13, 2025 20:53
@vercel
Copy link

vercel bot commented Nov 13, 2025

Deployment failed with the following error:

Too many requests - try again in 1 minute (more than 120, code: "api-deployments-flood-pro").

Learn More: https://vercel.com/docs/limits#rate-limits

@claude
Copy link

claude bot commented Nov 13, 2025

Code Review: Raw HTTP Connection Driver

Thank you for this contribution! This PR adds connection lifecycle management for raw HTTP requests, bringing consistency with how other connection types (WebSocket, HTTP actions) are handled. Overall, the implementation is solid and follows existing patterns. Here are my findings:


✅ Strengths

  1. Consistent Pattern: The implementation follows the same pattern as handleAction (router-endpoints.ts:319-378), using a try/finally block to ensure proper connection cleanup
  2. Good Documentation: The JSDoc comment in raw-http.ts clearly explains the purpose and how it differs from the standard HTTP driver
  3. Appropriate Driver Implementation: The createRawHttpSocket driver correctly implements the ConnDriver interface with minimal overhead for HTTP's stateless nature
  4. Clean Refactoring: The router changes simplify the handler by moving logic into a dedicated function

🐛 Potential Issues

Critical: Missing Parameters in connDisconnected Call

Location: router-endpoints.ts:569

actor.connDisconnected(createdConn, true);

Issue: The connDisconnected method signature expects only 2 parameters:

connDisconnected(conn: Conn<S, CP, CS, V, I, DB>, wasClean: boolean)

However, the underlying ConnectionManager.connDisconnected requires 4 parameters (instance/connection-manager.ts:98-103):

async connDisconnected(
    conn: Conn<S, CP, CS, V, I, DB>,
    wasClean: boolean,
    actorDriver: ActorDriver,
    eventManager: any,
)

Why This Works: The instance wrapper (instance/mod.ts:479-486) handles passing the additional parameters internally, so your code is actually correct. This is consistent with other handlers like handleAction (line 360) and handleRawWebSocketHandler (line 484).

Status: ✅ No issue - just wanted to note this for understanding


Minor: Missing Request Parameter Documentation

Location: router-endpoints.ts:548-572

The handleRawHttpHandler function passes req as the third parameter to createConn:

const conn = await actor.createConn(createRawHttpSocket(), {}, req);

However, the raw-http.ts driver doesn't document that this request parameter is tracked by the connection system. Consider adding a comment explaining this, similar to how other handlers document their parameters.


Minor: Inconsistent Driver Method Signature

Location: raw-http.ts:21-24

getConnectionReadyState: (): DriverReadyState | undefined => {
    return DriverReadyState.OPEN;
},

Issue: The ConnDriver interface defines getConnectionReadyState as:

getConnectionReadyState(
    actor: AnyActorInstance,
    conn: AnyConn,
): DriverReadyState | undefined;

Your implementation omits the parameters. While this works in JavaScript/TypeScript, it's inconsistent with:

  • The interface definition (conn/driver.ts:41-44)
  • The http.ts driver (line 10-12) which includes parameter names
  • The raw-websocket.ts driver (line 45-50) which uses the parameters

Recommendation: Add the parameters for consistency, even if unused:

getConnectionReadyState: (_actor, _conn): DriverReadyState | undefined => {
    return DriverReadyState.OPEN;
},

🚀 Performance Considerations

  1. ✅ Efficient: HTTP connections are properly cleaned up immediately (wasClean: true), preventing memory leaks
  2. ✅ No Overhead: The driver implementation has minimal overhead with noop operations where appropriate
  3. ✅ Request ID Generation: Using crypto.randomUUID() is appropriate for the stateless nature of HTTP

🔒 Security Concerns

No security issues identified. The implementation:

  • ✅ Properly cleans up connections in finally blocks
  • ✅ Doesn't expose sensitive connection internals
  • ✅ Follows the same security patterns as existing handlers

🧪 Test Coverage

Status: ⚠️ Missing Tests

This PR doesn't include tests for the new functionality. Consider adding:

  1. Unit test for createRawHttpSocket:

    • Verify requestId generation
    • Verify getConnectionReadyState returns OPEN
    • Verify disconnect is a noop
  2. Integration test for handleRawHttpHandler:

    • Verify connection is created and tracked
    • Verify connection is cleaned up after request completes
    • Verify connection cleanup happens even on handler errors
    • Verify request is passed correctly to onRequest handler

Example test location: rivetkit-typescript/packages/rivetkit/tests/raw-http-connection.test.ts


📝 Recommendations Summary

Must Fix

None - the code is functional as-is

Should Fix

  1. ✅ Add unused parameters to getConnectionReadyState in raw-http.ts:21 for consistency with the interface

Nice to Have

  1. Add tests for the new connection driver and handler
  2. Add comment in handleRawHttpHandler documenting the request parameter

📚 Additional Context

The implementation correctly mirrors the handleAction pattern where HTTP connections are:

  1. Created before the request is processed
  2. Tracked in the actor's connection manager
  3. Cleaned up immediately after (wasClean: true) since HTTP is stateless
  4. Properly cleaned up even on errors via finally block

This provides connection lifecycle observability for raw HTTP requests, which is valuable for debugging and monitoring.


✨ Conclusion

This is a solid implementation that follows existing patterns well. The only minor improvement would be parameter consistency in the driver. Great work! 🚀

@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 13, 2025

Merge activity

  • Nov 13, 9:15 PM UTC: NathanFlurry added this pull request to the Graphite merge queue.
  • Nov 13, 9:15 PM UTC: CI is running for this pull request on a draft pull request (#3465) due to your merge queue CI optimization settings.
  • Nov 13, 9:16 PM UTC: Merged by the Graphite merge queue via draft PR: #3465.

@graphite-app graphite-app bot closed this Nov 13, 2025
@graphite-app graphite-app bot deleted the 11-09-chore_rivetkit_add_connection_for_raw_http branch November 13, 2025 21:16
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.

3 participants