From 1c622a3bed0735dbd467fb28b57317b93e0937c4 Mon Sep 17 00:00:00 2001 From: M3gA-Mind Date: Fri, 23 Oct 2026 18:47:56 +0530 Subject: [PATCH] test(module): wait for the setup future to be reattached before asserting it is retained A setup poll takes the initial future out of its slot, polls it with no lock held and puts it back. The rejected-spawn retention test sampled the slot directly, so a slow runner could catch it mid-poll and see it empty. Wait, bounded, for the future to be back in its slot, as the physical-completion test already does for its anchor. --- crates/tinybus-module/src/lib_terminal_tests.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/tinybus-module/src/lib_terminal_tests.rs b/crates/tinybus-module/src/lib_terminal_tests.rs index a0080d38..946f0130 100644 --- a/crates/tinybus-module/src/lib_terminal_tests.rs +++ b/crates/tinybus-module/src/lib_terminal_tests.rs @@ -796,6 +796,17 @@ async fn actual_linked_rejected_physical_spawn_retains_received_resources_withou assert_eq!(fixture.requests.load(Ordering::Acquire), 1); assert_eq!(fixture.finishes.load(Ordering::Acquire), 0); let anchored = terminal::TerminalState::lookup(context).unwrap(); + // A setup poll takes the future out of its slot and puts it back once the + // poll returns; wait for it to be reattached instead of sampling the slot + // while a poll still holds it. + let initial_future = anchored.resources.lock().unwrap().initial_future.clone(); + tokio::time::timeout(Duration::from_secs(5), async { + while initial_future.lock().unwrap().is_none() { + tokio::task::yield_now().await; + } + }) + .await + .expect("the retained initial future must be reattached to its slot"); let resources = anchored.resources.lock().unwrap(); assert!(resources.retained_factory.is_some()); assert!(resources.runtime.is_some());