// libSQL error reference

Transaction timed-out: interactive transaction aborted

Interactive transactions fail on clients or servers old enough to predate Hrana-over-HTTP streams, or when the server expires an idle stream; batches still work.

Erro
Transaction timed-out
Categoria
Remote server and Hrana errors
Mensagem de erro
interactive transaction not allowed in HTTP queries

O que significa

Older sqld versions refused interactive transactions on stateless HTTP requests with exactly this message; current clients open a stream over HTTP (baton streams) and db.transaction() works with https:// URLs. The failure is still real in three shapes: a pinned old client or server, a literal BEGIN sent as a pipeline statement, and interactive transactions left idle until the server expires the stream (The stream has expired due to inactivity) or times the transaction out (Transaction timed-out).

Causas comuns

  • A client or server old enough to predate Hrana-over-HTTP streams.
  • A literal BEGIN (ou COMMIT) sent as a statement through a pipeline request.
  • An interactive transaction held open so long the server expired or timed it out.

Find the cause

Check the client version and URL scheme first: an up-to-date client on `https://` supports transactions, so the refusal points at a pinned old dependency. A bare `BEGIN` in a pipeline is refused or strands state, so use the transaction API or a batch. If the transaction worked and then died, the server expired the idle stream; keep interactive transactions short.

Como corrigir

  1. Upgrade the client first. Current @libsql/client runs db.transaction() over https URLs; long interactive sessions still do best on a WebSocket (libsql://) connection:

    const db = createClient({ url: 'libsql://mydb-myorg.turso.io', authToken });
    const tx = await db.transaction('write');
  2. On HTTP-only clients, replace the transaction with a batch, which is atomic on the server:

    await db.batch([
      { sql: 'UPDATE accounts SET bal = bal - 10 WHERE id = 1', args: [] },
      { sql: 'UPDATE accounts SET bal = bal + 10 WHERE id = 2', args: [] }
    ], 'write');
  3. Never send BEGIN/COMMIT yourself over HTTP:

    -- wrong over https:// URLs
    -- BEGIN;
    -- UPDATE ...;
    -- COMMIT;

Other ways to handle it

db.batch() runs all statements atomically on the server and works over any connection; for logic that decides statements mid-flight, keep the interactive transaction short or move the decision into one SQL statement with CTEs.

Reproduza com segurança

Local and honest for the idle-stream shape: run `turso dev --db-file scratch.db`, open a transaction over any URL scheme with @libsql/client, and wait past the server's inactivity expiry; the next statement fails with the stream expired error. The legacy refusal itself only reproduces on an old pinned client or server version.

Perguntas

Can I use db.transaction() with an https:// URL in @libsql/client?

Yes in current versions: the HTTP client opens a server-side stream and the transaction runs on it. Very old client or server versions refused interactive transactions over HTTP; if you see that refusal, upgrade before restructuring code.

Why did my interactive transaction die after a pause?

The server expires idle streams (The stream has expired due to inactivity) and times out stale transactions (Transaction timed-out). Keep interactive transactions short, or express the work as a batch, which commits or rolls back as a unit.

Can I send BEGIN and COMMIT as plain statements over HTTP?

No. Over HTTP each pipeline request should be self-contained; use the client's transaction API or db.batch(), which run inside an implicit server-side transaction.

Erros relacionados

More remote server and hrana errors errors

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.

// menos erros, correções mais rápidas

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.