@@ -464,7 +464,13 @@ export class Context extends RpcTarget {
464464 const sleepLogWrittenKey = `${ cacheKey } -log-written` ;
465465 const maybeResult = await this . #state. storage . get ( sleepKey ) ;
466466
467- const disableSleeps = await this . #state. storage . get ( "disableSleeps" ) ;
467+ const sleepNameCountHash = await computeHash (
468+ name + this . #getCount( "sleep-" + name )
469+ ) ;
470+ const disableThisSleep = await this . #state. storage . get ( sleepNameCountHash ) ;
471+ const disableAllSleeps = await this . #state. storage . get ( "disableAllSleeps" ) ;
472+
473+ const disableSleep = disableAllSleeps || disableThisSleep ;
468474
469475 if ( maybeResult != undefined ) {
470476 // @ts -expect-error priorityQueue is initiated in init
@@ -474,7 +480,7 @@ export class Context extends RpcTarget {
474480 // in case the engine dies while sleeping and wakes up before the retry period
475481 if ( entryPQ !== undefined ) {
476482 await scheduler . wait (
477- disableSleeps ? 0 : entryPQ . targetTimestamp - Date . now ( )
483+ disableSleep ? 0 : entryPQ . targetTimestamp - Date . now ( )
478484 ) ;
479485 // @ts -expect-error priorityQueue is initiated in init
480486 this . #engine. priorityQueue . remove ( { hash : cacheKey , type : "sleep" } ) ;
@@ -513,13 +519,12 @@ export class Context extends RpcTarget {
513519 // @ts -expect-error priorityQueue is initiated in init
514520 await this . #engine. priorityQueue . add ( {
515521 hash : cacheKey ,
516- targetTimestamp : Date . now ( ) + ( disableSleeps ? 0 : duration ) ,
522+ targetTimestamp : Date . now ( ) + ( disableSleep ? 0 : duration ) ,
517523 type : "sleep" ,
518524 } ) ;
519525
520- console . log ( "disable sleeps:" , disableSleeps ) ;
521526 // this probably will never finish except if sleep is less than the grace period
522- await scheduler . wait ( disableSleeps ? 0 : duration ) ;
527+ await scheduler . wait ( disableSleep ? 0 : duration ) ;
523528
524529 this . #engine. writeLog (
525530 InstanceEvent . SLEEP_COMPLETE ,
0 commit comments