tursodatabase / libsql-client-go

Go client API for libSQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Driver didn't handle hrana stream expiration, will error every ~300s of idle time

intagaming opened this issue · comments

The Go driver will error "Received an invalid baton" when the db connection idles for about > 300s. Related code here: https://github.com/libsql/sqld/blob/919bee19214669bbaf5268ecb81b0b3961b699fe/sqld/src/hrana/http/stream.rs#L317C52-L317C52

In the demo repo below I set the interval between queries = 500s.

https://github.com/intagaming/sqld-error

Clone the repo and run it with DATABASE_URL=http://127.0.0.1:8989 go run .. You can start a sqld instance with docker run -p 8989:8080 -d ghcr.io/libsql/sqld:latest.

image

When a client connects to sqld over HTTP (using Hrana over HTTP), the SQL connection (Hrana stream) will be closed after 10 seconds of inactivity; however, the server still remembers the stream for 300 seconds, so that it can provide a more useful error message. If the Go client reports an error after 300 seconds, perhaps it (incorrectly) relies on the STREAM_EXPIRED error?

The client should use Hrana over WebSocket, it would not have this issue.