tursodatabase/turso · error · TypeError

The transaction has already completed

Error message

The transaction has already completed

What it means

Error "The transaction has already completed" thrown in tursodatabase/turso.

Source

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

  constructor(db: NativeDatabase, ioStep: () => Promise<void>) {
    this.db = db;
    this.ioStep = ioStep;
    const lock = new AsyncLock();
    this.gate = {
      acquire: async () => { this.assertActive(); await lock.acquire(); },
      release: () => { lock.release(); },
    };
  }

  /** Whether the transaction is still open (COMMIT/ROLLBACK not executed yet). */
  get open(): boolean {
    return this.active;
  }

  private assertActive() {
    if (!this.active) {
      throw new TypeError("The transaction has already completed");
    }
  }

  /** @internal Marks the transaction completed; called by the wrapper. */
  finish() {
    this.active = false;
  }

  /**
   * Executes the given SQL string inside the transaction.
   * Unlike prepared statements, this can execute strings that contain multiple SQL statements.
   *
   * @param {string} sql - The string containing SQL statements to execute
   */
  async exec(sql: string, queryOptions?: QueryOptions) {
    await this.gate.acquire();
    try {
      const exec = this.db.executor(sql, queryOptions);

View on GitHub (pinned to bad083fafb)

When it happens

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