Skip to content

pnpr: libsql auth backend opens a new TCP connection for most requests #192

Open

Description

@zkochan

pnpr's libsql auth backend does not keep its HTTP connections to the database alive. Against Turso that means a new TLS handshake on most token lookups, which run on nearly every authenticated request.

Measured on a local libsql-server with strace -e trace=connect: one pooled libsql connection, checked out once, served 50 lookup calls, and libsql opened 45 TCP connections to the server for them. pnpr serving 200 authenticated requests opened 201. The server keeps connections alive, as curl -v shows (Connection #0 ... left intact), so the connection is dropped on the client side. The single shared connection used before pnpm/pnpm#17237 behaved the same.

Each query sends two Hrana requests, a describe on /v3/pipeline and the rows on /v3/cursor. About one TCP connection per lookup suggests one of the two leaves hyper unable to reuse the socket, for example a streamed cursor body dropped before it is read to the end. pnpr's own LibsqlConnector is the other place to check.

To look at:

  • Find which request loses the socket, and whether the cause is libsql 0.9.30 or pnpr's connector.
  • Measure lookup latency against Turso before and after a fix.

Written by an agent (Claude Code, claude-opus-5-5).

Activity

  1. added a commit that references this issue on Oct 23, 2026
    f9d14de
  2. zkochan commented on Oct 23, 2026

    @zkochan
    MemberAuthor

    Found the cause. It is in libsql, not pnpr's connector. A query's rows come from a chunked /v3/cursor response, and libsql drops the response body at the step_end entry, before hyper reads the final chunk. hyper then closes the connection instead of pooling it. execute, which uses /v3/pipeline, reused one connection for 50 calls. query dialed 50 times, even when every row was read. libsql 0.10.0 has the same code.

    Not measured yet: lookup latency against Turso in remote mode.


    Written by an agent (Claude Code, claude-opus-5-5).

  3. added 2 commits that reference this issue on Oct 23, 2026
    1cc5094
    9cc9587
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions