File tree Expand file tree Collapse file tree
rivetkit-typescript/packages/rivetkit/src/registry Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3950,16 +3950,19 @@ export function buildNativeFactory(
39503950 const actorCtx = makeActorCtx ( ctx ) ;
39513951 try {
39523952 if ( onSleep ) {
3953- await onSleep ( actorCtx ) ;
3954- if ( runtime . kind === "wasm" ) {
3955- // Wasm cannot use the native context save helper here because
3956- // the runtime owns the serialized state handoff.
3957- await runtime . actorSaveState (
3958- ctx ,
3959- actorCtx . serializeForTick ( "save" ) ,
3960- ) ;
3961- } else {
3962- await actorCtx . saveState ( { immediate : true } ) ;
3953+ try {
3954+ await onSleep ( actorCtx ) ;
3955+ } finally {
3956+ if ( runtime . kind === "wasm" ) {
3957+ // Wasm cannot use the native context save helper here because
3958+ // the runtime owns the serialized state handoff.
3959+ await runtime . actorSaveState (
3960+ ctx ,
3961+ actorCtx . serializeForTick ( "save" ) ,
3962+ ) ;
3963+ } else {
3964+ await actorCtx . saveState ( { immediate : true } ) ;
3965+ }
39633966 }
39643967 }
39653968 } finally {
You can’t perform that action at this time.
0 commit comments