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

エラー
Transaction timed-out
カテゴリ
Remote server and Hrana errors
エラーメッセージ
interactive transaction not allowed in HTTP queries

意味

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

よくある原因

  • A client or server old enough to predate Hrana-over-HTTP streams.
  • A literal BEGIN (または 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.

修正方法

  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.

安全に再現する

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.

質問

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.

関連エラー

More remote server and hrana errors errors

コードとメッセージのテキストは、 libSQL / Turso documentation。全容は次で参照 libSQL error list または すべてのデータベースエラーを検索.

// エラーが減り、修正も速く

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.

このページのテキストとデータ: CC BY 4.0、出典は SQLly (sqlly.app) と明記してください。 コードと SQL スニペット: MIT. ライセンスの詳細 引用したエラーメッセージの文言は、各データベースベンダーに帰属します。