Craft Anything: understand how any software works, and craft your own.
Rust
Verify stand-in session cleanup by answerer lifetime (#677)
Afloat2122a619e946
diff --git a/crates/engine/src/tools/standin_tools/tests.rs b/crates/engine/src/tools/standin_tools/tests.rsindex af7b0782..043492d4 100644--- a/crates/engine/src/tools/standin_tools/tests.rs+++ b/crates/engine/src/tools/standin_tools/tests.rs@@ -181,11 +181,16 @@ fn starting_twice_reuses_and_a_session_ending_stops_it() {assert_eq!(b["result"]["already_running"], true);let url = a["result"]["url"].as_str().unwrap().to_string();assert!(get(&url, "/users/1").contains("Pat"));- let port: u16 = url.rsplit(':').next().unwrap().parse().unwrap();+ let answerer = {+ let registry = e.session().ext.get::<StandIns>().unwrap();+ let running = registry.running.lock().unwrap();+ Arc::downgrade(&running.get(a["result"]["id"].as_str().unwrap()).unwrap().replay)+ };+ assert!(answerer.upgrade().is_some(), "the original answerer is running");drop(e);let until = std::time::Instant::now() + Duration::from_secs(5);- while TcpStream::connect(("127.0.0.1", port)).is_ok() {- assert!(std::time::Instant::now() < until, "ending the session stops it");+ while answerer.upgrade().is_some() {+ assert!(std::time::Instant::now() < until, "ending the session releases its answerer");std::thread::sleep(Duration::from_millis(20));}});diff --git a/docs/ROADMAP.md b/docs/ROADMAP.mdindex ff6b6aa2..5ee13baa 100644--- a/docs/ROADMAP.md+++ b/docs/ROADMAP.md@@ -596,6 +596,9 @@ Owner: open · Status: in progress### R3.11 Single-file apps, game files and stand-in backendsOwner: open · Status: in progress+- [x] Verify stand-in session cleanup by the original answerer's lifetime rather than polling a+ released port that another listener may reuse+ — claimed: Afloat16, branch test/r3.11-standin-session-lifetime-20261103- [ ] Stand-in backend: writes that change later reads (recorded answers are replayed as they are)- [ ] Tell the builder about the stand-in backend in a website's brief, and start one from arecording