File tree Expand file tree Collapse file tree
rivetkit-typescript/packages/rivetkit/fixtures/driver-test-suite Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -486,6 +486,8 @@ export const sleepEnqueue = actor({
486486 } ,
487487} ) ;
488488
489+ const scheduleAfterKeepAwakeResolvers = new Map < string , ( ) => void > ( ) ;
490+
489491export const sleepScheduleAfter = actor ( {
490492 state : {
491493 startCount : 0 ,
@@ -508,7 +510,11 @@ export const sleepScheduleAfter = actor({
508510 c . state . startCount += 1 ;
509511 if ( c . state . holdAfterWake ) {
510512 // Keep the alarm wake observable before idle sleep can run again.
511- c . setPreventSleep ( true ) ;
513+ c . keepAwake (
514+ new Promise < void > ( ( resolve ) => {
515+ scheduleAfterKeepAwakeResolvers . set ( c . actorId , resolve ) ;
516+ } ) ,
517+ ) ;
512518 }
513519 await c . db . execute (
514520 `INSERT INTO sleep_log (event, created_at) VALUES ('wake', ${ Date . now ( ) } )` ,
@@ -539,7 +545,8 @@ export const sleepScheduleAfter = actor({
539545 } ;
540546 if ( c . state . scheduledActionCount > 0 ) {
541547 c . state . holdAfterWake = false ;
542- c . setPreventSleep ( false ) ;
548+ scheduleAfterKeepAwakeResolvers . get ( c . actorId ) ?.( ) ;
549+ scheduleAfterKeepAwakeResolvers . delete ( c . actorId ) ;
543550 }
544551 return counts ;
545552 } ,
You can’t perform that action at this time.
0 commit comments