rivet-dev / rivet-dev/agentos

Sidecar panics with "RefCell already mutably borrowed" when cancelling a running execution

Open
#1,988 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
4.6k
Forks
251
Avg merge
2d 15h
Merged PRs (30d)
34

Description

Aborting an in-flight JavaScript execution makes the cancel request panic in the sidecar.

Repro

const vm = await AgentOs.create();
const controller = new AbortController();
setTimeout(() => controller.abort(), 500);
await vm.javascript.execute("await new Promise((r) => setTimeout(r, 60_000))", { signal: controller.signal });

Actual

  • The call resolves cancelled, but the cancel request fails with ERR_AGENTOS_REQUEST_TASK_PANIC: … "RefCell already mutably borrowed" at crates/native-sidecar/src/state.rs:1079.
  • vm.dispose() then waits out ERR_AGENTOS_VM_TEARDOWN_DEADLINE.
  • The same panic fails 2 of 18 tests in crates/native-sidecar/tests/language_execution.rs (background_lifecycle_replays_cancels_resets_and_deletes, package_mutations_are_exclusive_across_executions).

Expected
Cancel completes without a panic, and dispose returns promptly.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the cancellation case from the JavaScript example, then inspect crates/native-sidecar/src/state.rs:1079 and the failing scenarios in crates/native-sidecar/tests/language_execution.rs. Verify the fix against background_lifecycle_replays_cancels_resets_and_deletes and package_mutations_are_exclusive_across_executions; done means cancellation no longer panics and vm.dispose() returns promptly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, rust
Domain
backend, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.