Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions crates/tinybus/src/module/resolve_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,21 @@ mod resolver {
})
}

async fn wait_until_attached(record: &ReleaseRecord) {
for _ in 0..2000 {
if shared_runtime()
.host()
.list()
.iter()
.any(|info| info.manifest.bus_name.as_str() == record.bus_name)
{
return;
}
tokio::time::sleep(Duration::from_millis(5)).await;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Replace sleep-based attachment polling with an explicit notification

This helper synchronizes the setup-fault test by repeatedly sleeping until attachment becomes visible, contrary to the explicit AGENTS.md requirement that tests never use sleep as synchronization. It also introduces a scheduler-dependent retry budget into the test intended to eliminate a CI race. Await an explicit attachment notification instead, with tokio::time::timeout providing the failure deadline.

AGENTS.md reference: AGENTS.md:L64-L66

Useful? React with 👍 / 👎.

}
panic!("module never finished attaching");
}

slow_setup_module!(
init_then_fault,
faulting_factory,
Expand All @@ -1452,6 +1467,10 @@ mod resolver {
async move { resolver.ensure_loaded(record.id).await }
});
FAULTING_ENTERED.notified().await;
// `init` signals from inside attachment; faulting before the host has
// registered the module races admission instead of exercising a fault
// raised during setup.
wait_until_attached(record).await;
FAULTING_HANDLE.lock().unwrap().as_ref().unwrap().fault();

let error = load.await.unwrap().unwrap_err();
Expand Down
Loading