Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cloudflare-workers/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export default defineConfig({
test: {
...defaultConfig.test,
// Requires time for installing packages
testTimeout: 15_000,
testTimeout: 60_000,
},
});
35 changes: 28 additions & 7 deletions packages/rivetkit/src/driver-test-suite/tests/actor-conn-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,30 +162,51 @@ export function runActorConnStateTests(driverTestConfig: DriverTestConfig) {
});

// Initial disconnection count
const initialDisconnections = await conn.getDisconnectionCount();
await vi.waitFor(async () => {
const disconnects = await conn.getDisconnectionCount();
expect(disconnects).toBe(0);
});

// Dispose the connection
await conn.dispose();

// Validate conn count
await vi.waitFor(
async () => {
const disconnects = await newConn.getDisconnectionCount();
expect(disconnects).toBe(1);
},
// SSE takes a long time to disconnect on CF Workers
{
timeout: 10_000,
interval: 100,
},
);

// Create a new connection to check the disconnection count
const newConn = handle.connect();

// Verify the connection is tracked
await vi.waitFor(async () => {
const connectionIds = await conn.getConnectionIds();
expect(connectionIds.length).toBe(2);
});

// Clean up
await newConn.dispose();

// Verify disconnection was tracked
await vi.waitFor(
async () => {
const newDisconnections = await newConn.getDisconnectionCount();

expect(newDisconnections).toBeGreaterThan(initialDisconnections);
const disconnects = await newConn.getDisconnectionCount();
expect(disconnects).toBe(2);
},
// SSE takes a long time to disconnect on CF Workers
{
timeout: 10_000,
interval: 100,
},
);

// Clean up
await newConn.dispose();
});

test("should update connection state", async (c) => {
Expand Down
Loading