diff --git a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-conn-hibernation.ts b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-conn-hibernation.ts index 9a1bd358fa..fb5c6ac441 100644 --- a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-conn-hibernation.ts +++ b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-conn-hibernation.ts @@ -3,6 +3,9 @@ import { HIBERNATION_SLEEP_TIMEOUT } from "../../../fixtures/driver-test-suite/h import type { DriverTestConfig } from "../mod"; import { setupDriverTest, waitFor } from "../utils"; +// TODO(RVT-6193): Several tests below use fixed waitFor windows around +// hibernation handoff. Those waits should go away once requests block until +// the next ready actor generation instead of probing shutdown timing. export function runActorConnHibernationTests( driverTestConfig: DriverTestConfig, ) { diff --git a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-db-pragma-migration.ts b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-db-pragma-migration.ts index df9f666815..8864a873e4 100644 --- a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-db-pragma-migration.ts +++ b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-db-pragma-migration.ts @@ -98,6 +98,8 @@ export function runActorDbPragmaMigrationTests( // Sleep and wake await actor.triggerSleep(); + // TODO(RVT-6193): This fixed delay should not be needed. + // The follow up request should block until the woken actor is ready. await waitFor(driverTestConfig, SLEEP_WAIT_MS); // After wake, onMigrate runs again but should not fail diff --git a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-db.ts b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-db.ts index 01f692fd0d..34e238e7a5 100644 --- a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-db.ts +++ b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-db.ts @@ -33,6 +33,8 @@ const HOT_ROW_UPDATES = 240; const INTEGRITY_SEED_COUNT = 64; const INTEGRITY_CHURN_COUNT = 120; +// TODO(RVT-6193): Sleep and wake routing should hide this transient lifecycle +// error from callers instead of forcing tests to special case it. function isActorStoppingDbError(error: unknown): boolean { return ( error instanceof Error && @@ -171,6 +173,9 @@ export function runActorDbTests(driverTestConfig: DriverTestConfig) { for (let i = 0; i < 3; i++) { await actor.triggerSleep(); + // TODO(RVT-6193): This fixed delay should not be needed. + // Requests after sleep should wait for the next ready + // actor generation instead of probing the handoff window. await waitFor(driverTestConfig, SLEEP_WAIT_MS); let countAfterWake = -1; @@ -476,6 +481,8 @@ export function runActorDbTests(driverTestConfig: DriverTestConfig) { ); await actor.triggerSleep(); + // TODO(RVT-6193): This fixed delay should not be needed. + // The post sleep request should route once the actor is ready. await waitFor(driverTestConfig, SLEEP_WAIT_MS + 100); expect((await actor.integrityCheck()).toLowerCase()).toBe( "ok", diff --git a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-inspector.ts b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-inspector.ts index 36f581ffd6..4a22553ebf 100644 --- a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-inspector.ts +++ b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-inspector.ts @@ -15,6 +15,8 @@ function buildInspectorUrl( return url.toString(); } +// TODO(RVT-6193): Sleep and wake routing should hide this transient lifecycle +// error from callers instead of forcing tests to special case it. function isActorStoppingDbError(error: unknown): boolean { return ( error instanceof Error && @@ -418,6 +420,8 @@ export function runActorInspectorTests(driverTestConfig: DriverTestConfig) { if (!isActorStoppingDbError(error)) { throw error; } + // TODO(RVT-6193): This retry delay should not be needed. + // The request should wait for the next ready actor generation. await waitFor(driverTestConfig, 25); } } diff --git a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-sleep-db.ts b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-sleep-db.ts index 33330fc64b..f7204b38a1 100644 --- a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-sleep-db.ts +++ b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-sleep-db.ts @@ -64,6 +64,9 @@ async function waitForConnected( ); } +// TODO(RVT-6193): Several tests below use fixed waitFor windows around sleep +// and wake handoff. Those waits should go away once requests block until the +// next ready actor generation instead of probing shutdown timing. export function runActorSleepDbTests(driverTestConfig: DriverTestConfig) { const describeSleepDbTests = driverTestConfig.skip?.sleep ? describe.skip diff --git a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-sleep.ts b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-sleep.ts index 72ddb826aa..6cf3ff97cb 100644 --- a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-sleep.ts +++ b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-sleep.ts @@ -91,7 +91,8 @@ export function runActorSleepTests(driverTestConfig: DriverTestConfig) { // Trigger sleep await sleepActor.triggerSleep(); - // HACK: Wait for sleep to finish in background + // TODO(RVT-6193): This fixed delay should not be needed. + // The next request should wait for the woken actor generation. await waitFor(driverTestConfig, 250); // Get sleep count after restore diff --git a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-state-zod-coercion.ts b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-state-zod-coercion.ts index 581c67c164..056be692fd 100644 --- a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-state-zod-coercion.ts +++ b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-state-zod-coercion.ts @@ -19,6 +19,8 @@ export function runActorStateZodCoercionTests( // Sleep and wake await actor.triggerSleep(); + // TODO(RVT-6193): This fixed delay should not be needed. + // The next request should wait for the woken actor generation. await waitFor(driverTestConfig, SLEEP_WAIT_MS); const state = await actor.getState(); @@ -49,6 +51,8 @@ export function runActorStateZodCoercionTests( // Sleep await actor.triggerSleep(); + // TODO(RVT-6193): This fixed delay should not be needed. + // The next request should wait for the woken actor generation. await waitFor(driverTestConfig, SLEEP_WAIT_MS); // Wake and verify Zod parse preserved values diff --git a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-workflow.ts b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-workflow.ts index 2ee0d82a56..c6a503a499 100644 --- a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-workflow.ts +++ b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/actor-workflow.ts @@ -7,6 +7,8 @@ import { import type { DriverTestConfig } from "../mod"; import { setupDriverTest, waitFor } from "../utils"; +// TODO(RVT-6193): Sleep and wake routing should hide this transient lifecycle +// error from callers instead of forcing tests to special case it. function isActorStoppingConnectionError(error: unknown): boolean { return ( error instanceof Error && @@ -484,6 +486,8 @@ export function runActorWorkflowTests(driverTestConfig: DriverTestConfig) { expect(state.wakeCount).toBe(1); await actor.triggerSleep(); + // TODO(RVT-6193): This fixed delay should not be needed. + // The follow up request should wait for the next ready generation. await waitFor(driverTestConfig, 250); let resumedState = await actor.getErrorState(); diff --git a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/hibernatable-websocket-protocol.ts b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/hibernatable-websocket-protocol.ts index e61bff8299..948ccaf6d7 100644 --- a/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/hibernatable-websocket-protocol.ts +++ b/rivetkit-typescript/packages/rivetkit/src/driver-test-suite/tests/hibernatable-websocket-protocol.ts @@ -5,6 +5,9 @@ import { setupDriverTest, waitFor } from "../utils"; const HIBERNATABLE_ACK_SETTLE_TIMEOUT_MS = 12_000; +// TODO(RVT-6193): Several tests below use fixed waitFor windows around +// hibernation handoff. Those waits should go away once requests block until +// the next ready actor generation instead of probing shutdown timing. async function waitForJsonMessage( ws: WebSocket, timeoutMs: number,