From 659798e5f937f4c7d6699e96c57640c3b007161e Mon Sep 17 00:00:00 2001 From: faumaray Date: Sat, 24 Oct 2026 02:02:07 +0300 Subject: [PATCH] Keep the account watches of a session made outside an engine open A TeamSpeak session made through the plain Connector interface (the way the conformance suite and any client of the seam that is no engine make one) got a LocalCtx::standalone() whose only job is to hold the senders of the myTeamSpeak watches. connect_link dropped that context when it returned, the senders went with it, and the TeamSpeak link ends its connection with "account source closed" when a watch has no sender: the session died by itself a moment after it was handed out. The engine's own path was never affected, its watches belong to the engine. The context now moves into the driver task and lives as long as the session. Found by running the link conformance suite against the development servers: close_ends_the_session passed vacuously and the_backend_can_end_the_session saw the session end with that text. The new test fails without this change ("the identity watch lost its sender"). Co-Authored-By: Claude Sonnet 5.5 --- crates/voelin-core/src/link/tests.rs | 15 +++++++++++++++ crates/voelin-core/src/ts_session/mod.rs | 9 ++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/crates/voelin-core/src/link/tests.rs b/crates/voelin-core/src/link/tests.rs index 9d37375..ab1bf27 100644 --- a/crates/voelin-core/src/link/tests.rs +++ b/crates/voelin-core/src/link/tests.rs @@ -1308,6 +1308,21 @@ async fn a_session_closes_as_the_table_says() { assert!(matches!(error, SessionError::Closed(_)), "{error:?}"); } +/// A session made through the plain `Connector` interface, outside an engine +/// (the conformance suite does, so does any client of the seam that is no +/// engine), has no engine to hold the account watches the link listens to: +/// the session keeps their senders for as long as it runs. The link ends its +/// connection with "account source closed" when it has lost them. +#[tokio::test(flavor = "multi_thread")] +async fn a_session_made_outside_an_engine_keeps_the_watches_of_its_link_open() { + let (session, _pushes, inner) = open(everything()).await; + // Let the driver start, and the connect that returned drop what it held. + tokio::time::sleep(Duration::from_millis(50)).await; + assert!(inner.ctx.myts_identity.has_changed().is_ok(), "the identity watch lost its sender"); + assert!(inner.ctx.myts_data.has_changed().is_ok(), "the data watch lost its sender"); + drop(session); +} + #[tokio::test(flavor = "multi_thread")] async fn a_connect_that_the_link_fails_is_an_error_with_its_reason() { let (conns, mut seen) = mpsc::unbounded_channel(); diff --git a/crates/voelin-core/src/ts_session/mod.rs b/crates/voelin-core/src/ts_session/mod.rs index da67c7f..9558a50 100644 --- a/crates/voelin-core/src/ts_session/mod.rs +++ b/crates/voelin-core/src/ts_session/mod.rs @@ -703,7 +703,14 @@ async fn connect_link( closed: closed_rx, own_slot, }; - tokio::spawn(driver.run(cmds_rx)); + tokio::spawn(async move { + driver.run(cmds_rx).await; + // The context keeps the senders of the account watches that a connection + // made outside an engine has (`LocalCtx::standalone`): the link ends its + // connection when a watch has no sender, so the context lives as long as + // the session does. + drop(ctx); + }); Ok(LocalConnected { connected: Connected { session: Arc::new(session),