// 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. 授權詳情 引用的錯誤訊息文字歸其資料庫廠商所有。