From 6d7aefe27a0b9a76e2af166e590f305805dfe069 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 1 May 2025 09:02:16 -0600 Subject: [PATCH] remove unnecessary assertion from `subtask_cancel` If the task to be cancelled is yielding or was cancelled earlier, then an event will already have been set for that task, which is normal and does not indicate a bug. Fixes #146 Signed-off-by: Joel Dice --- crates/wasmtime/src/runtime/component/concurrent.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/wasmtime/src/runtime/component/concurrent.rs b/crates/wasmtime/src/runtime/component/concurrent.rs index 1fde72e083..a00790960d 100644 --- a/crates/wasmtime/src/runtime/component/concurrent.rs +++ b/crates/wasmtime/src/runtime/component/concurrent.rs @@ -2409,7 +2409,10 @@ impl ComponentInstance { // Started, but not yet returned or cancelled; send the // `CANCELLED` event task.cancel_sent = true; - assert!(task.event.is_none()); + // Note that this might overwrite an event that was set earlier + // (e.g. `Event::None` if the task is yielding, or + // `Event::Cancelled` if it was already cancelled), but that's + // okay -- this should supersede the previous state. task.event = Some(Event::Cancelled); if let Some(set) = task.waiting_on.take() { let item = match self.get_mut(set)?.waiting.remove(&guest_task).unwrap() {