fix: clear outbox when guest handle traps

When a guest calls swactor.send() then traps, the outbox entries from
the incomplete operation survived and leaked into the next successful
handle() call, delivering messages from a failed context. Now clears
the outbox on trap, consistent with the "drop everything from failed
operations" semantics.

Authored by Claude, lovingly guided by Zachery Aaron Shores-Chmielewski
This commit is contained in:
Claude 2026-02-13 08:46:58 +00:00
parent 148edb9ac5
commit 1be0281056
2 changed files with 1 additions and 1 deletions

View file

@ -50,6 +50,7 @@ impl ActorInterface for WasmActor {
// 3. Call guest handle // 3. Call guest handle
if self.handle.call(&mut self.store, (ptr, len)).is_err() { if self.handle.call(&mut self.store, (ptr, len)).is_err() {
self.store.data_mut().outbox.clear(); // discard sends from incomplete operation
return; // handle trapped — drop message, keep actor alive return; // handle trapped — drop message, keep actor alive
} }

View file

@ -743,7 +743,6 @@ fn native_actor_communicates_with_wasm_actor() {
// ── Stale outbox: sends before trap leak into next handle ───────────────────── // ── Stale outbox: sends before trap leak into next handle ─────────────────────
#[test] #[test]
#[ignore] // BUG: outbox not cleared on handle trap — stale entries leak into next call
fn outbox_entries_from_trapped_handle_do_not_leak_into_next_call() { fn outbox_entries_from_trapped_handle_do_not_leak_into_next_call() {
// A guest that calls swactor.send() successfully, then traps. // A guest that calls swactor.send() successfully, then traps.
// The outbox contains the send from before the trap. // The outbox contains the send from before the trap.