// 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.

Erreur
Transaction timed-out
Catégorie
Remote server and Hrana errors
Message d'erreur
interactive transaction not allowed in HTTP queries

Ce que cela signifie

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).

Causes courantes

  • 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.

Comment le corriger

  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.

Reproduisez-le en toute sécurité

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.

Questions

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.

Erreurs liées

More remote server and hrana errors errors

Le code et le texte du message sont issus de libSQL / Turso documentation. Parcourir la liste complète libSQL error list ou Rechercher toutes les erreurs de base de données.

// moins d'erreurs, corrections plus rapides

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.

Texte et données de cette page : CC BY 4.0, en citant SQLly (sqlly.app). Code et extraits SQL : MIT. Détails de la licence Le texte des messages d’erreur cité appartient à l’éditeur de la base de données.