@@ -3,12 +3,18 @@ import { HIBERNATION_SLEEP_TIMEOUT } from "../../../fixtures/driver-test-suite/h
33import type { DriverTestConfig } from "../mod" ;
44import { setupDriverTest , waitFor } from "../utils" ;
55
6+ async function waitForHibernatableRegistration (
7+ driverTestConfig : DriverTestConfig ,
8+ ) : Promise < void > {
9+ await waitFor ( driverTestConfig , 100 ) ;
10+ }
11+
612export function runActorConnHibernationTests (
713 driverTestConfig : DriverTestConfig ,
814) {
9- describe . skipIf ( driverTestConfig . skip ?. hibernation ) (
10- "Connection Hibernation" ,
11- ( ) => {
15+ describe
16+ . skipIf ( driverTestConfig . skip ?. hibernation )
17+ . sequential ( "Connection Hibernation" , ( ) => {
1218 test ( "basic conn hibernation" , async ( c ) => {
1319 const { client } = await setupDriverTest ( c , driverTestConfig ) ;
1420
@@ -20,6 +26,7 @@ export function runActorConnHibernationTests(
2026 // Initial RPC call
2127 const ping1 = await hibernatingActor . ping ( ) ;
2228 expect ( ping1 ) . toBe ( "pong" ) ;
29+ await waitForHibernatableRegistration ( driverTestConfig ) ;
2330
2431 // Trigger sleep
2532 await hibernatingActor . triggerSleep ( ) ;
@@ -64,6 +71,7 @@ export function runActorConnHibernationTests(
6471 await hibernatingActor . getActorCounts ( ) ;
6572 expect ( initialActorCounts . wakeCount ) . toBe ( 1 ) ;
6673 expect ( initialActorCounts . sleepCount ) . toBe ( 0 ) ;
74+ await waitForHibernatableRegistration ( driverTestConfig ) ;
6775
6876 // Trigger sleep
6977 await hibernatingActor . triggerSleep ( ) ;
@@ -113,6 +121,7 @@ export function runActorConnHibernationTests(
113121 } ) ;
114122
115123 for ( let i = 0 ; i < 2 ; i ++ ) {
124+ await waitForHibernatableRegistration ( driverTestConfig ) ;
116125 await hibernatingActor . triggerSleep ( ) ;
117126 await waitFor (
118127 driverTestConfig ,
@@ -140,6 +149,7 @@ export function runActorConnHibernationTests(
140149
141150 // Initial RPC call
142151 await conn1 . ping ( ) ;
152+ await waitForHibernatableRegistration ( driverTestConfig ) ;
143153
144154 // Get connection ID
145155 const connectionIds = await conn1 . getConnectionIds ( ) ;
@@ -196,6 +206,7 @@ export function runActorConnHibernationTests(
196206 await vi . waitFor ( async ( ) => {
197207 expect ( connection . isConnected ) . toBe ( true ) ;
198208 } ) ;
209+ await waitForHibernatableRegistration ( driverTestConfig ) ;
199210
200211 const sleepingPromise = new Promise < void > ( ( resolve ) => {
201212 connection . once ( "sleeping" , ( ) => {
@@ -241,6 +252,5 @@ export function runActorConnHibernationTests(
241252 await connection . dispose ( ) ;
242253 }
243254 } ) ;
244- } ,
245- ) ;
255+ } ) ;
246256}
0 commit comments