Skip to content

fix(api): make actor destroy wait for ack#4327

Open
MasterPtato wants to merge 1 commit into02-27-chore_flatten_runtime_configfrom
02-27-fix_api_make_actor_destroy_wait_for_ack
Open

fix(api): make actor destroy wait for ack#4327
MasterPtato wants to merge 1 commit into02-27-chore_flatten_runtime_configfrom
02-27-fix_api_make_actor_destroy_wait_for_ack

Conversation

@MasterPtato
Copy link
Contributor

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 Feb 27, 2026

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

Service Status Web Updated (UTC)
frontend-cloud 😴 Sleeping (View Logs) Web Mar 6, 2026 at 5:13 pm
website 😴 Sleeping (View Logs) Web Feb 28, 2026 at 11:53 pm
frontend-inspector 😴 Sleeping (View Logs) Web Feb 28, 2026 at 9:00 pm
mcp-hub ✅ Success (View Logs) Web Feb 27, 2026 at 11:49 pm
ladle ❌ Build Failed (View Logs) Web Feb 27, 2026 at 11:49 pm

Copy link
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link

claude bot commented Feb 27, 2026

PR Review: fix(api): make actor destroy wait for ack

The fix is correct and the approach is sound. A few observations:

Correct subscription ordering. Subscribing to DestroyComplete before sending the Destroy signal eliminates the race where the event could be emitted between sending the signal and setting up the subscription. This is the right pattern.

Parallel fetching. Running actor::get and namespace::resolve_for_name_global concurrently with tokio::try_join! is a nice incidental improvement.

Explicit destroy_ts guard. The early return on actor.destroy_ts.is_some() is important for correctness: without it, an already-destroyed actor would still proceed past validation, send a signal that returns None (workflow gone), skip destroy_sub.next(), and succeed silently. Now it returns NotFound consistently, which matches caller expectations.


Concerns:

No timeout on destroy_sub.next().await?. If the destroy workflow stalls (stuck activity, infrastructure issue), this call will hang until the request times out at a higher level. If there is no upstream request timeout, the call hangs indefinitely. Consider wrapping with tokio::time::timeout and returning an appropriate error.

Concurrent delete requests sharing the same DestroyComplete event. If two requests concurrently delete the same actor, both subscribe to the topic before sending the signal. The first sends Destroy and triggers the workflow; the second may also get res = Some(...) (workflow still alive at signal time), so both enter the else branch and call destroy_sub.next().await?. Whether both subscribers receive the event depends on the pub/sub semantics of ctx.subscribe. If the message is consumed rather than broadcast, one caller could hang. Worth verifying.

Subscription created before validation. The subscription is set up unconditionally before confirming the actor exists or belongs to the right namespace. Requests that fail validation create and immediately drop a subscription. This is minor overhead but should be fine assuming subscription setup has no significant server-side cost.


Minor: The PR description template was not filled in. It would help to note the user-visible behavior change (DELETE now blocks until the actor is fully torn down) and any impact on clients that expect a fast response.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 27, 2026

More templates

@rivetkit/cloudflare-workers

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

@rivetkit/framework-base

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

@rivetkit/next-js

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

@rivetkit/react

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

rivetkit

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

@rivetkit/sql-loader

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

@rivetkit/sqlite-vfs

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

@rivetkit/traces

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

@rivetkit/workflow-engine

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

@rivetkit/virtual-websocket

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

@rivetkit/engine-runner

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

@rivetkit/engine-runner-protocol

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

commit: 96bf39a

@MasterPtato MasterPtato mentioned this pull request Mar 2, 2026
11 tasks
@MasterPtato MasterPtato force-pushed the 02-27-chore_flatten_runtime_config branch from 1622668 to 06bdd41 Compare March 3, 2026 00:06
@MasterPtato MasterPtato force-pushed the 02-27-fix_api_make_actor_destroy_wait_for_ack branch from ec5ffcb to c88c25b Compare March 3, 2026 00:06
@MasterPtato MasterPtato force-pushed the 02-27-chore_flatten_runtime_config branch from 06bdd41 to 9df506d Compare March 6, 2026 02:16
@MasterPtato MasterPtato force-pushed the 02-27-fix_api_make_actor_destroy_wait_for_ack branch from c88c25b to c2fcae4 Compare March 6, 2026 02:16
@MasterPtato MasterPtato mentioned this pull request Mar 6, 2026
11 tasks
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