tursodatabase/turso · error · TypeError

transactionAsync() callbacks receive a Transaction handle as

Error message

transactionAsync() callbacks receive a Transaction handle as their first argument and must declare it: db.transactionAsync(async (txn, ...args) => { await txn.run(...) }). Statements inside the callback must go through the handle - database-level calls wait for the transaction to finish and deadlock it if awaited inside the callback.

What it means

Error "transactionAsync() callbacks receive a Transaction handle as their first argument and must declare it: db.transactionAsync(async (txn, ...args) => { await txn.run(...) }). Statements inside the callback must go through the handle - database-level calls wait for the transaction to finish and deadlock it if awaited inside the callback." thrown in tursodatabase/turso.

Source

Thrown at bindings/javascript/packages/common/promise.ts:152

    rows,
    rowsAffected,
  };
}

/**
 * Rejects transaction callbacks that cannot be using the `Transaction`
 * handle. A callback that declares no parameters is the pre-0.8 shape:
 * its statements target the `Database` and would deadlock against the
 * lock its own transaction holds. `fn.length` counts declared parameters,
 * so rest-only signatures (`(...args)`) are rejected too — the handle
 * parameter must be declared explicitly.
 */
function assertTransactionCallback(fn: Function) {
  if (typeof fn !== "function") {
    throw new TypeError("Expected first argument to be a function");
  }
  if (fn.length === 0) {
    throw new TypeError(
      "transactionAsync() callbacks receive a Transaction handle as their first argument " +
      "and must declare it: db.transactionAsync(async (txn, ...args) => { await txn.run(...) }). " +
      "Statements inside the callback must go through the handle - database-level calls " +
      "wait for the transaction to finish and deadlock it if awaited inside the callback.",
    );
  }
}

/**
 * A wrapped transaction function. Calling it runs the wrapped function inside a
 * `BEGIN`/`COMMIT` block; the mode properties (`deferred`, `concurrent`, etc.)
 * return equivalent wrappers that begin the transaction with the corresponding
 * locking mode.
 *
 * @deprecated Returned by the deprecated `Database.transaction()`; use
 * `Database.transactionAsync()` and {@link AsyncTransactionFunction} instead.
 */
export interface TransactionFunction<

View on GitHub (pinned to bad083fafb)

When it happens

Trigger: Thrown at bindings/javascript/packages/common/promise.ts:152 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tursodatabase/turso@bad083fafb (2026-08-16). Data as JSON: /api/errors/a9c498b0602f41fc. Report an issue: GitHub.