{"record":{"id":"e866941d67f43e6d","repo":"tursodatabase/turso","slug":"expected-first-argument-to-be-an-array-of-statemen-e86694","errorCode":null,"errorMessage":"Expected first argument to be an array of statements","messagePattern":"Expected first argument to be an array of statements","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"bindings/javascript/packages/common/promise.ts","lineNumber":469,"sourceCode":"   * await db.batch([\n   *   { sql: \"INSERT INTO users(name) VALUES (?)\", args: [\"Eve\"] },\n   *   { sql: \"INSERT INTO users(name) VALUES (?)\", args: [\"Frank\"] },\n   * ], \"immediate\");\n   *\n   * @example\n   * // Atomic via the transactionAsync() API for mixed workloads.\n   * const txn = db.transactionAsync(async (tx) => {\n   *   await tx.batch([{ sql: \"INSERT INTO users(name) VALUES (?)\", args: [\"Eve\"] }]);\n   *   await tx.exec(\"UPDATE counters SET n = n + 1\");\n   * });\n   * await txn.immediate();\n   */\n  async batch(\n    statements: Array<string | { sql: string; args?: any[] | Record<string, any> }>,\n    options?: BatchMode | BatchOptions,\n  ): Promise<ResultSet[]> {\n    if (!Array.isArray(statements)) {\n      throw new TypeError(\"Expected first argument to be an array of statements\");\n    }\n    if (!this.connected) {\n      await this.connect();\n    }\n    if (!this.open) {\n      throw new TypeError(\"The database connection is not open\");\n    }\n\n    // Hold execLock across the entire batch so it is observed as a\n    // single unit by other callers on this connection. The helper\n    // runs its own step loops without re-acquiring the lock.\n    await this.execLock.acquire();\n    try {\n      return await executeBatch(this.db, () => this.io(), statements, options);\n    } finally {\n      this.execLock.release();\n    }\n  }","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/javascript/packages/common/promise.ts#L451-L487","documentation":"Error \"Expected first argument to be an array of statements\" thrown in tursodatabase/turso.","triggerScenarios":"Thrown at bindings/javascript/packages/common/promise.ts:469 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"}