{"record":{"id":"a9c498b0602f41fc","repo":"tursodatabase/turso","slug":"transactionasync-callbacks-receive-a-transaction","errorCode":null,"errorMessage":"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.","messagePattern":"transactionAsync\\(\\) callbacks receive a Transaction handle as their first argument and must declare it: db\\.transactionAsync\\(async \\(txn, \\.\\.\\.args\\) => (.+?)\\)\\. 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\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"bindings/javascript/packages/common/promise.ts","lineNumber":152,"sourceCode":"    rows,\n    rowsAffected,\n  };\n}\n\n/**\n * Rejects transaction callbacks that cannot be using the `Transaction`\n * handle. A callback that declares no parameters is the pre-0.8 shape:\n * its statements target the `Database` and would deadlock against the\n * lock its own transaction holds. `fn.length` counts declared parameters,\n * so rest-only signatures (`(...args)`) are rejected too — the handle\n * parameter must be declared explicitly.\n */\nfunction assertTransactionCallback(fn: Function) {\n  if (typeof fn !== \"function\") {\n    throw new TypeError(\"Expected first argument to be a function\");\n  }\n  if (fn.length === 0) {\n    throw new TypeError(\n      \"transactionAsync() callbacks receive a Transaction handle as their first argument \" +\n      \"and must declare it: db.transactionAsync(async (txn, ...args) => { await txn.run(...) }). \" +\n      \"Statements inside the callback must go through the handle - database-level calls \" +\n      \"wait for the transaction to finish and deadlock it if awaited inside the callback.\",\n    );\n  }\n}\n\n/**\n * A wrapped transaction function. Calling it runs the wrapped function inside a\n * `BEGIN`/`COMMIT` block; the mode properties (`deferred`, `concurrent`, etc.)\n * return equivalent wrappers that begin the transaction with the corresponding\n * locking mode.\n *\n * @deprecated Returned by the deprecated `Database.transaction()`; use\n * `Database.transactionAsync()` and {@link AsyncTransactionFunction} instead.\n */\nexport interface TransactionFunction<","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/javascript/packages/common/promise.ts#L134-L170","documentation":"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.","triggerScenarios":"Thrown at bindings/javascript/packages/common/promise.ts:152 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}