Skip to content

docs(actors): clarify saveState immediate vs throttled flush behavior#4510

Merged
NathanFlurry merged 1 commit intomainfrom
03-25-docs_actors_clarify_savestate_immediate_vs_throttled_flush_behavior
Mar 25, 2026
Merged

docs(actors): clarify saveState immediate vs throttled flush behavior#4510
NathanFlurry merged 1 commit intomainfrom
03-25-docs_actors_clarify_savestate_immediate_vs_throttled_flush_behavior

Conversation

@NathanFlurry
Copy link
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@railway-app
Copy link

railway-app bot commented Mar 25, 2026

🚅 Deployed to the rivet-pr-4510 environment in rivet-frontend

Service Status Web Updated (UTC)
kitchen-sink 🕒 Building (View Logs) Web Mar 25, 2026 at 8:09 pm
mcp-hub ✅ Success (View Logs) Web Mar 25, 2026 at 8:08 pm
website 🕒 Building (View Logs) Web Mar 25, 2026 at 8:07 pm
frontend-inspector 😴 Sleeping (View Logs) Web Mar 25, 2026 at 5:57 pm
frontend-cloud 😴 Sleeping (View Logs) Web Mar 25, 2026 at 5:57 pm
ladle ❌ Build Failed (View Logs) Web Mar 25, 2026 at 5:44 pm

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 25, 2026

More templates

@rivetkit/virtual-websocket

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/virtual-websocket@4510

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/cloudflare-workers@4510

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/framework-base@4510

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/next-js@4510

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/react@4510

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivet/rivetkit@4510

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sql-loader@4510

@rivetkit/sqlite-vfs

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sqlite-vfs@4510

@rivetkit/traces

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/traces@4510

@rivetkit/workflow-engine

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/workflow-engine@4510

@rivetkit/engine-runner

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner@4510

@rivetkit/engine-runner-protocol

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner-protocol@4510

commit: 9165d2c

@claude
Copy link

claude bot commented Mar 25, 2026

PR Review: docs(actors): clarify saveState immediate vs throttled flush behavior

This is a small, focused documentation addition to website/src/content/docs/actors/state.mdx that explains the two modes of c.saveState(). I verified the content against the implementation in rivetkit-typescript/packages/rivetkit/src/actor/instance/state-manager.ts.

Accuracy Check

  • Immediate mode ({ immediate: true }): Calls savePersistInner() directly - accurate
  • Throttled mode (default): Schedules via savePersistThrottled(), awaits next flush cycle - accurate
  • Default interval of 10 seconds: Matches stateSaveInterval: default(10_000) in actor/config.ts - accurate

Suggestions

Minor: maxWait option is undocumented

SaveStateOptions also exposes a maxWait field (maximum milliseconds before forcing a flush). It is a useful middle ground between full-immediate and fully-throttled saves that is worth a brief mention, e.g. c.saveState({ maxWait: 1000 }).

Minor: throttled behavior description is slightly imprecise

The doc says 'await will not resolve until the next flush cycle, which can take up to stateSaveInterval'. In practice the throttled path resolves sooner when a save was recently completed; it only approaches the full interval when no prior save has occurred recently. A small clarification like 'up to stateSaveInterval if no recent save has occurred' would be more accurate and avoid surprising callers.

Overall

Good addition. The distinction between immediate and throttled saves is non-obvious and worth documenting. The WebSocket handler callout at the end is helpful context. Both suggestions above are optional; the PR is mergeable as-is.

@NathanFlurry NathanFlurry changed the base branch from 03-24-fix_rivetkit_copy_buffer_to_uint8array_in_ensureuint8array_to_fix_.slice_semantics to graphite-base/4510 March 25, 2026 20:03
@NathanFlurry NathanFlurry force-pushed the 03-25-docs_actors_clarify_savestate_immediate_vs_throttled_flush_behavior branch from 9165d2c to a98b9ee Compare March 25, 2026 20:07
@graphite-app graphite-app bot changed the base branch from graphite-base/4510 to main March 25, 2026 20:07
@graphite-app
Copy link
Contributor

graphite-app bot commented Mar 25, 2026

Merge activity

  • Mar 25, 8:07 PM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.
  • Mar 25, 8:09 PM UTC: Graphite rebased this pull request as part of a merge.
  • Mar 25, 8:10 PM UTC: @NathanFlurry merged this pull request with Graphite.

@NathanFlurry NathanFlurry force-pushed the 03-25-docs_actors_clarify_savestate_immediate_vs_throttled_flush_behavior branch from a98b9ee to 4b39547 Compare March 25, 2026 20:08
@NathanFlurry NathanFlurry merged commit 6cc3f06 into main Mar 25, 2026
14 of 19 checks passed
@NathanFlurry NathanFlurry deleted the 03-25-docs_actors_clarify_savestate_immediate_vs_throttled_flush_behavior branch March 25, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant