You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Review: fix(rivetkit-core): always signal actor stop handle on teardown failure
Summary
This fixes a real bug: previously, shutdown_started_instance used ? on the join outcome (join.await.context(...)?.context(...)?), so a failing actor task join would early-return beforestop_handle.complete()/stop_handle.fail() was ever called. That drops the stop_handle oneshot unsignaled, and any waiter (e.g. an envoy caller awaiting the stop handle) would see a generic "channel closed" error instead of a structured RivetError. The fix folds the join result into final_result alongside shutdown_result so the stop handle is always signaled on the way out, matching the "Fail-By-Default Runtime" guidance in CLAUDE.md (no early-return around required lifecycle/teardown signaling).
Correctness
The refactor is sound: join_result and shutdown_result are computed independently, then combined with .and(...), and stop_handle is signaled unconditionally afterward via match &final_result. RivetError::extract(error) correctly takes &anyhow::Error, matching the borrow from match &final_result { Err(error) => ... }.
Priority when both shutdown_result and join_result fail: shutdown_result wins via .and(...), and the discarded join error is logged via tracing::warn! with structured fields (discarded_join_error) rather than silently dropped, matching the structured-logging convention in CLAUDE.md.
instance.ctx.configure_lifecycle_events(None) still runs unconditionally after the join, same as before; no behavior change there.
Test coverage gap
No regression test exercises this exact fix. tests/modules/registry.rs::stop_actor_for_test bypasses shutdown_started_instance/RegistryDispatcher::stop_actor entirely: it calls ActorLifecycle::shutdown_for_sleep/shutdown_for_destroy directly and never touches instance.join or stop_handle. So there is currently no test that would catch a regression back to the old ?-early-return behavior, for example if this function gets refactored later and the ? is reintroduced, stop_handle would silently go unsignaled again with no test failure. Given the bug being fixed is precisely that stop_handle was not reliably signaled, it would be worth adding a test that forces the actor task join to fail (or drops it) and asserts stop_handle still resolves with a structured error rather than hanging or surfacing a channel-closed error.
Minor
The log message says "only the shutdown error is returned." Worth keeping in mind that the log wording and the actual .and(...) precedence are two separate pieces of code that could silently drift out of sync in a future change.
Overall this is a small, well-scoped, low-risk fix in the right place (rivetkit-core, per the layer architecture rules). The main gap is test coverage for the exact failure mode being fixed.
Base automatically changed from
stack/fix-envoy-client-ack-terminating-stop-commands-so-pegboard-envoy-stops-replaying-them-zrklppqy to
mainAugust 31, 2026 14:13
abcxff
changed the base branch from
main
to
stack/fix-workflow-engine-mark-completed-inner-loop-iterations-visited-on-resume-vqowwtqxAugust 31, 2026 15:01
abcxff
changed the base branch from
stack/fix-workflow-engine-mark-completed-inner-loop-iterations-visited-on-resume-vqowwtqx
to
stack/fix-rivetkit-expose-engine-ray-ids-on-errors-for-debug-kzmlwrllAugust 31, 2026 17:07
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
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.
No description provided.