connection reset / interrupted: Connection reset or dropped
The network path to the server dropped mid-request: the socket closed, the request timed out, or a proxy cut the connection.
- Erro
connection reset / interrupted- Categoria
- Remote server and Hrana errors
O que significa
Remote libSQL runs over HTTP/WebSocket. Any hop between client and server can drop: TLS handshake failure, a load balancer idle timeout, a WebSocket closed by the server, or plain network loss. The client sees a closed socket or an interrupted request rather than a server error, so no HTTP status arrives. These failures are usually transient, and a retry often succeeds.
Causas comuns
- Network loss between client and server, including wifi and VPN blips.
- An idle WebSocket closed by a proxy or load balancer timeout.
- Server restart or failover on the remote database.
- The client gave up on a request that exceeded its own timeout.
Find the cause
Decide first whether writes may have been applied before the drop: if the connection died mid-transaction, the transaction rolled back; if it died mid-batch with individual autocommit statements, some may have applied. Check by reading the data. Then look at where it dropped: a timeout with no bytes returned points at the network or proxy; a clean close right after connect points at the server refusing or restarting. `curl` to the same URL from the same machine separates your client from the network.
Como corrigir
-
Retry idempotent reads and use transactions for multi-statement writes so a dropped connection cannot leave partial state:
await db.batch(['INSERT ...', 'UPDATE ...'], 'write');
-
Check reachability and latency by hand when it recurs:
curl -s -o /dev/null -w '%{http_code} %{time_total}\n' https://mydb-myorg.turso.io/v2/pipeline -
Wrap remote calls in your own timeout; @libsql/client has no request timeout for remote clients (its
timeoutconfig is a local-file busy timeout):const res = await Promise.race([ db.execute(sql), new Promise((_, rej) => setTimeout(() => rej(new Error('client timeout')), 10_000)) ]);
Other ways to handle it
For HTTP-only clients, prefer the /v2/pipeline endpoint, which is stateless per request, over interactive transactions that need a live session. For flaky networks, embedded replicas keep reads local.
Reproduza com segurança
Local and honest: start `turso dev --db-file scratch.db`, open a client, then kill the turso process mid-request to get a socket close. Real-world flakiness (proxies, TLS, wifi) cannot be reproduced offline; the kill-based repro only covers the server-gone-away shape.
Perguntas
If the connection drops mid-transaction, did my writes apply?
An interactive transaction rolls back when its connection dies. A batch is atomic: all of it applies or none. Individual autocommit statements that already returned stay applied, so read the data back to check rather than replaying blindly.
Does @libsql/client have a request timeout option?
Not for remote clients. The timeout config sets a busy timeout and only affects local file: databases. For remote calls, wrap the promise in your own timeout (Promise.race with a rejected timer, or an AbortSignal on a custom fetch).
Why do my WebSocket connections die after quiet periods?
Proxies and load balancers close idle sockets. For long idle periods prefer the HTTP pipeline shape, or issue a cheap keepalive statement; either way treat the closed socket as a retryable failure.
Erros relacionados
404 Not Found404 Not Found: unknown database or endpointSQLITE_BUSY: database is lockedembedded replica file lockedtoo many connectionsToo many connections to one database
More remote server and hrana errors errors
429 Too Many Requestsrequest rate limit hitTransaction timed-outinteractive transaction abortedError in remote responseError in remote response500 Internal Server Errorserver failed on a valid request402 Payment Required402 Payment Required409 Conflict409 Conflictdatabase not foundturso CLI: database not found
O código e o texto da mensagem são de libSQL / Turso documentation. Veja toda a libSQL error list ou pesquise todos os erros do banco de dados.
Work on libSQL in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for libSQL and the other databases you use.
Texto e dados desta página: CC BY 4.0, com crédito ao SQLly (sqlly.app). Código e trechos SQL: MIT. Detalhes da licença O texto citado das mensagens de erro pertence ao fornecedor do banco de dados.