tursodatabase/turso · error · TypeError
Expected first argument to be a function
Error message
Expected first argument to be a function
What it means
Error "Expected first argument to be a function" thrown in tursodatabase/turso.
Source
Thrown at bindings/javascript/packages/common/promise.ts:149
return {
columns,
columnTypes,
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()`; useView on GitHub (pinned to bad083fafb)
When it happens
Trigger: Thrown at bindings/javascript/packages/common/promise.ts:149 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/17976ccec815f435.
Report an issue: GitHub.