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
ReviewThe change is small, focused and matches the PR description. The lifecycle gating reads correctly, and the error follows the existing Things to check
Overall this looks good, pending the docs-gen check and the race confirmation. |
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
eersnington
force-pushed
the
fix/rivetkit-restarting-after-on-sleep
branch
from
October 16, 2026 23:44
638369f to
bfd367a
Compare
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. So an action dispatched during that window ran against an actor thatonSleepwas tearing down.SleepFinalizerefused withactor.stopping, which does not tell sleep from destroy.Now dispatch stays open only while the sleep hooks still run. After they finish, it refuses with the new
actor.restartingerror. The action did not run, and the error is retryable.StartedSleepGrace,onSleepor connection disconnects runningSleepGrace, after those hooksactor.restarting(503), not runSleepFinalizeactor.stoppingactor.restarting(503), not runDestroyGraceactor.stoppingactor.stoppingThe check reuses the existing
core_dispatched_hookscounter, which counts the graceful cleanup and connection disconnects thatemit_grace_eventsstarts. No new state. #5860 moves the refusal point to the start of the hooks.ws.going_away(fix(rivetkit-core): close drained connections with ws.going_away #5867) instead, because the connection closes before the reply arrives. In both cases the action did not run.rivetkit-rust/packages/rivetkit-core/src/error.rs: addsActorLifecycle::Restarting(actor.restarting, "Actor is restarting. Retry the request.") with status 503. It matches the TypeScriptactorRestarting()error that the client already classifies as retryable.rivetkit-rust/engine/artifacts/errors/actor.restarting.json: generated error artifact.docs-internal/engine/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: