tursodatabase/turso · error · TypeError

The database connection is not open

Error message

The database connection is not open

What it means

Error "The database connection is not open" thrown in tursodatabase/turso.

Source

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

  /**
   * connect database
   */
  async connect() {
    if (this.connected) { return; }
    await this.db.connectAsync();
    this.connected = true;
  }

  /**
   * Prepares a SQL statement for execution.
   *
   * @param {string} sql - The SQL statement string to prepare.
   */
  prepare(sql: string): Promise<Statement> {
    // Only throw if we connected before but now the database is closed
    // Allow implicit connection if not connected yet
    if (this.connected && !this.open) {
      throw new TypeError("The database connection is not open");
    }
    if (!sql) {
      throw new RangeError("The supplied SQL string contains no statements");
    }

    try {
      if (this.connected) {
        return new Statement(maybeValue(this.db.prepare(sql)), this.db, this.execLock, this.ioStep) as unknown as Promise<Statement>;
      } else {
        return new Statement(maybePromise(() => this.connect().then(() => this.db.prepare(sql))), this.db, this.execLock, this.ioStep) as unknown as Promise<Statement>;
      }
    } catch (err) {
      throw convertError(err);
    }
  }

  /**
   * Returns a function that executes the given function in a transaction.

View on GitHub (pinned to bad083fafb)

When it happens

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