`cloudflare` feature: hrana streams are never closed

Open Beginner friendly
#2,312 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 11 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
databases

Research direction

Read libsql/src/hrana/stream.rs and compare the RawStream Drop implementation’s feature gate with the cloudflare feature configuration. Confirm the behavior with default-features = false, features = ["cloudflare"] by checking whether dropping a stream sends a close request. Done when streams opened with that configuration are closed on drop.

Written by the indexing model from the issue text.

Description

Summary

With default-features = false, features = ["cloudflare"], the client never sends a close request for the hrana streams it opens. The Drop impl that sends it is compiled only with the remote feature.

Where

libsql/src/hrana/stream.rs. The code is identical in 0.9.30, 0.10.0 and current main:

#[cfg(feature = "remote")]
impl<T> Drop for RawStream<T>
where
    T: HttpSend,
{
    fn drop(&mut self) {
        let baton = self.baton.get_mut().take();
        if let Some(baton) = baton {
            // ... sends StreamRequest::Close via self.client.oneshot(...)
        }
    }
}

With only cloudflare enabled, this impl does not exist, so dropping a RawStream sends nothing.

What we observed

Setup:

  • libsql 0.9.30 (default-features = false, features = ["cloudflare"])
  • worker 0.6.7, wrangler dev 4.105.0
  • local sqld 0.24.31 with default settings

We sent a few dozen sequential requests to the worker; each request runs several statements. Every query after that failed. sqld logged:

ERROR libsql_server::hrana::http: hrana server: Timed out while opening database connection
ERROR libsql_server::error: HTTP API: 429 Too Many Requests, DbCreateTimeout

The client got:

Hrana: `api error: `{"error":"Timed out while opening database connection"}``

After restarting sqld with --max-concurrent-connections 4096 --max-concurrent-requests 4096, the same requests (over 200 sequential ones) succeeded.

Dominant language
C
Stars
17.3k
Forks
557
Avg merge
10d 15h
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tursodatabase/libsql

All issues in tursodatabase/libsql

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.