tursodatabase/turso · error · TypeError

Expected first argument to be an array of statements

Error message

Expected first argument to be an array of statements

What it means

Error "Expected first argument to be an array of statements" thrown in tursodatabase/turso.

Source

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

   * await db.batch([
   *   { sql: "INSERT INTO users(name) VALUES (?)", args: ["Eve"] },
   *   { sql: "INSERT INTO users(name) VALUES (?)", args: ["Frank"] },
   * ], "immediate");
   *
   * @example
   * // Atomic via the transactionAsync() API for mixed workloads.
   * const txn = db.transactionAsync(async (tx) => {
   *   await tx.batch([{ sql: "INSERT INTO users(name) VALUES (?)", args: ["Eve"] }]);
   *   await tx.exec("UPDATE counters SET n = n + 1");
   * });
   * await txn.immediate();
   */
  async batch(
    statements: Array<string | { sql: string; args?: any[] | Record<string, any> }>,
    options?: BatchMode | BatchOptions,
  ): Promise<ResultSet[]> {
    if (!Array.isArray(statements)) {
      throw new TypeError("Expected first argument to be an array of statements");
    }
    if (!this.connected) {
      await this.connect();
    }
    if (!this.open) {
      throw new TypeError("The database connection is not open");
    }

    // Hold execLock across the entire batch so it is observed as a
    // single unit by other callers on this connection. The helper
    // runs its own step loops without re-acquiring the lock.
    await this.execLock.acquire();
    try {
      return await executeBatch(this.db, () => this.io(), statements, options);
    } finally {
      this.execLock.release();
    }
  }

View on GitHub (pinned to bad083fafb)

When it happens

Trigger: Thrown at bindings/javascript/packages/common/promise.ts:469 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/e866941d67f43e6d. Report an issue: GitHub.