Repository navigation
fix(rivetkit): refuse actions after onSleep with actor.restarting - #5876
Open
eersnington wants to merge 2 commits into
Open
eersnington wants to merge 2 commits into
eersnington wants to merge 2 commits into
Conversation
|
This PR was not deployed automatically as @eersnington does not have access to the Railway project. In order to get automatic PR deploys, please add @eersnington to your workspace on Railway. |
Contributor
|
Review The approach is sound. Reusing Issues
Tests
Nits
|
eersnington
force-pushed
the
fix/rivetkit-restarting-after-on-sleep
branch
from
October 14, 2026 20:40
2edecfb to
638369f
Compare
eersnington
changed the base branch from
main
to
fix/drain-going-away-close-reason
October 14, 2026 20:40
eersnington
added this pull request to stack #5879
October 14, 2026 20:40
This was referenced Oct 14, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sleep grace accepted new actions for its whole duration. The TypeScript sleep hook runs the app's
onSleep, then closes SQLite and clears runtime state such asvars. An action dispatched after that ran against a torn-down actor and failed with plain errors orrivetkit.internal_error.SleepFinalizerefused withactor.stopping, which the client does not retry.Now dispatch stays open only while the sleep hooks still run. After they finish, it refuses with the new
actor.restartingerror, and the client retries the action against the next generation.StartedSleepGrace,onSleepor connection disconnects runningSleepGrace, after those hooksactor.restarting(503), client retriesSleepFinalizeactor.stoppingactor.restarting(503), client retriesDestroyGraceactor.stoppingactor.stoppingThe check reuses the existing
core_dispatched_hookscounter, which counts the graceful cleanup and connection disconnects thatemit_grace_eventsstarts. No new state.error.rs: addsActorLifecycle::Restarting(actor.restarting, "Actor is restarting. Retry the request.") with status 503. It matches the TypeScriptactorRestarting()error that the client already retries.rivetkit-rust/engine/artifacts/errors/actor.restarting.json: generated error artifact.sleep-sequence.md: documents when sleep grace admits work.actor-sleep-db.test.ts:broadcast works in onSleepcallsgetCountsthrough a closure. The connection proxy readgetCounts.bindas an action name, so the test failed before sleep started.This is part 4 of 6 in a stack: