Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions rivetkit-typescript/packages/rivetkit/src/registry/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3950,16 +3950,19 @@ export function buildNativeFactory(
const actorCtx = makeActorCtx(ctx);
try {
if (onSleep) {
await onSleep(actorCtx);
if (runtime.kind === "wasm") {
// Wasm cannot use the native context save helper here because
// the runtime owns the serialized state handoff.
await runtime.actorSaveState(
ctx,
actorCtx.serializeForTick("save"),
);
} else {
await actorCtx.saveState({ immediate: true });
try {
await onSleep(actorCtx);
} finally {
if (runtime.kind === "wasm") {
// Wasm cannot use the native context save helper here because
// the runtime owns the serialized state handoff.
await runtime.actorSaveState(
ctx,
actorCtx.serializeForTick("save"),
);
} else {
await actorCtx.saveState({ immediate: true });
}
}
}
} finally {
Expand Down
Loading