fix(net): prevent race to match mocked net requests
All checks were successful
Test / build (map[name:stable]) (push) Successful in 7m54s
Test / build (map[name:nightly]) (push) Successful in 6m40s
Release Please / Release-plz (push) Successful in 1m26s

This commit is contained in:
Paul Campbell 2024-12-25 19:17:59 +00:00
parent d3eb51ab73
commit 31354f74ef

View file

@ -62,7 +62,7 @@ impl Plan {
},
),
});
tracing::debug!(?is_match);
tracing::debug!(?is_match, plan = ?self);
is_match
}
}
@ -140,16 +140,15 @@ impl Net {
};
tracing::debug!("build request");
let request = request.build()?;
let index = plans
.lock()
.await
let locked_plans = plans.lock().await;
let index = locked_plans
.deref()
.borrow()
.iter()
.position(|plan| plan.matches(&request));
match index {
Some(i) => {
let plan = plans.lock().await.borrow_mut().remove(i);
let plan = locked_plans.borrow_mut().remove(i);
let response = plan.response;
if response.status().is_success() {
tracing::debug!(?request, "matched success response");