{"record":{"id":"17976ccec815f435","repo":"tursodatabase/turso","slug":"expected-first-argument-to-be-a-function-17976c","errorCode":null,"errorMessage":"Expected first argument to be a function","messagePattern":"Expected first argument to be a function","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"bindings/javascript/packages/common/promise.ts","lineNumber":149,"sourceCode":"  return {\n    columns,\n    columnTypes,\n    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","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/javascript/packages/common/promise.ts#L131-L167","documentation":"Error \"Expected first argument to be a function\" thrown in tursodatabase/turso.","triggerScenarios":"Thrown at bindings/javascript/packages/common/promise.ts:149 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"}