From faa16a49115d5b6332d6b2442d5697124f19dac3 Mon Sep 17 00:00:00 2001 From: "Levy A." Date: Thu, 19 Jun 2025 22:55:45 -0300 Subject: [PATCH 1/2] fix: ignore baton from cursor endpoint --- libsql/src/hrana/stream.rs | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/libsql/src/hrana/stream.rs b/libsql/src/hrana/stream.rs index c63f600c75..251ebbfa05 100644 --- a/libsql/src/hrana/stream.rs +++ b/libsql/src/hrana/stream.rs @@ -329,16 +329,7 @@ where self.pipeline_url = Arc::from(format!("{base_url}/v3/pipeline")); self.cursor_url = Arc::from(format!("{base_url}/v3/cursor")); } - match response.baton.take() { - None => { - tracing::trace!("client stream has been closed by the server"); - self.reset(); - } // stream has been closed by the server - Some(baton) => { - tracing::trace!("client stream has been assigned with baton: `{}`", baton); - self.baton = Some(baton) - } - } + self.reset(); Ok(cursor) } From 13ab2b7d15a49ae314d38d7e388bd41320db61ff Mon Sep 17 00:00:00 2001 From: "Levy A." Date: Sat, 21 Jun 2025 13:22:56 -0300 Subject: [PATCH 2/2] fix: keep using baton in transaction --- libsql/src/hrana/stream.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libsql/src/hrana/stream.rs b/libsql/src/hrana/stream.rs index 251ebbfa05..da606a198d 100644 --- a/libsql/src/hrana/stream.rs +++ b/libsql/src/hrana/stream.rs @@ -176,7 +176,7 @@ where pub async fn cursor(&self, batch: Batch) -> Result> { let mut client = self.inner.stream.lock().await; - let cursor = client.open_cursor(batch).await?; + let cursor = client.open_cursor(batch, !self.is_autocommit()).await?; Ok(cursor) } @@ -314,7 +314,7 @@ where Ok(resp) } - pub async fn open_cursor(&mut self, batch: Batch) -> Result> { + pub async fn open_cursor(&mut self, batch: Batch, use_baton: bool) -> Result> { let msg = CursorReq { baton: self.baton.clone(), batch, @@ -329,7 +329,16 @@ where self.pipeline_url = Arc::from(format!("{base_url}/v3/pipeline")); self.cursor_url = Arc::from(format!("{base_url}/v3/cursor")); } - self.reset(); + match response.baton.take() { + Some(baton) if use_baton => { + tracing::trace!("client stream has been assigned with baton: `{}`", baton); + self.baton = Some(baton) + } + _ => { + tracing::trace!("client stream has been closed by the server"); + self.reset(); + } + } Ok(cursor) }