tursodatabase / tursodatabase/libsql
The stream expired due to inactivity with SQLC and turso
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 17.2k
- Forks
- 531
- Avg merge
- 1h 12m
- Merged PRs (30d)
- 1
Description
I'm not sure what I might be doing wrong. Basically if I wait a short while before making first or second connection, I get:
error code = 1: Error executing statement: Hrana: `api error: `{"message":"The stream has expired due to inactivity","code":"STREAM_EXPIRED"}``
2024-08-15T13:47:59.110452Z ERROR libsql_server::hrana::http: hrana server: Stream handle for 15505556566524579603 is expired
I'm running it locally via turso dev --db-file=./dev.db
I'm not sure whether I should be pinging the server before every query? I've tried that, but it seems to not make any difference. Is there a way I should be connecting? I'm using a the most simple way via database/sql in golang. Just a plain ol' conn, err := sql.Open("libsql", "http://...")
The connection is the passed to the sqlc generated function: queries := db.New(conn) which is the passed around by pointer to my services and what not.
Is this the wrong approach or am I missing completely?
Quick edit:
By the looks of it it's only an issue if you're running tuso dev --db-file=.... Obviously, if you just directly point to the file everything is fine, and if you're using the Turso hosted DB it's also fine.
As I understand if you point it to your libsql:/<my-db>.turso.io it also connects via http? Why would it be any different in that case?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failure with turso dev --db-file=./dev.db, Go database/sql, and the sqlc-generated db.New(conn) path, using a delay before the first or second connection. Compare this with direct file access and a hosted Turso database. Done means the local HTTP connection no longer returns STREAM_EXPIRED after inactivity, or the issue clearly documents the required connection behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sqlite
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100