From da03110196bfde48090212175120ea97e8b512de Mon Sep 17 00:00:00 2001 From: Piotr Jastrzebski Date: Tue, 14 Nov 2023 19:18:02 +0100 Subject: [PATCH] Close streams asynchronously in ResetSession This is a temporary workaround for the server not supporting closing and opening a stream in a single pipeline request. Once https://github.com/tursodatabase/libsql/pull/621 is merged and deployed to all databases we can revert this commit. Signed-off-by: Piotr Jastrzebski --- libsql/internal/http/hranaV2/hranaV2.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libsql/internal/http/hranaV2/hranaV2.go b/libsql/internal/http/hranaV2/hranaV2.go index 8ecf009..41c7a3c 100644 --- a/libsql/internal/http/hranaV2/hranaV2.go +++ b/libsql/internal/http/hranaV2/hranaV2.go @@ -397,9 +397,12 @@ func (h *hranaV2Conn) closeStream(ctx context.Context) error { func (h *hranaV2Conn) ResetSession(ctx context.Context) error { if h.baton != "" { - err := h.closeStream(ctx) + go func(baton, url, jwt, host string) { + msg := hrana.PipelineRequest{Baton: baton} + msg.Add(hrana.CloseStream()) + _, _, _ = sendPipelineRequest(context.Background(), &msg, url, jwt, host) + }(h.baton, h.url, h.jwt, h.host) h.baton = "" - return err } return nil }