{"record":{"id":"298052d05e9f9747","repo":"tursodatabase/turso","slug":"the-transaction-has-already-completed","errorCode":null,"errorMessage":"The transaction has already completed","messagePattern":"The transaction has already completed","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"bindings/javascript/packages/common/promise.ts","lineNumber":812,"sourceCode":"\n  constructor(db: NativeDatabase, ioStep: () => Promise<void>) {\n    this.db = db;\n    this.ioStep = ioStep;\n    const lock = new AsyncLock();\n    this.gate = {\n      acquire: async () => { this.assertActive(); await lock.acquire(); },\n      release: () => { lock.release(); },\n    };\n  }\n\n  /** Whether the transaction is still open (COMMIT/ROLLBACK not executed yet). */\n  get open(): boolean {\n    return this.active;\n  }\n\n  private assertActive() {\n    if (!this.active) {\n      throw new TypeError(\"The transaction has already completed\");\n    }\n  }\n\n  /** @internal Marks the transaction completed; called by the wrapper. */\n  finish() {\n    this.active = false;\n  }\n\n  /**\n   * Executes the given SQL string inside the transaction.\n   * Unlike prepared statements, this can execute strings that contain multiple SQL statements.\n   *\n   * @param {string} sql - The string containing SQL statements to execute\n   */\n  async exec(sql: string, queryOptions?: QueryOptions) {\n    await this.gate.acquire();\n    try {\n      const exec = this.db.executor(sql, queryOptions);","sourceCodeStart":794,"sourceCodeEnd":830,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/javascript/packages/common/promise.ts#L794-L830","documentation":"Error \"The transaction has already completed\" thrown in tursodatabase/turso.","triggerScenarios":"Thrown at bindings/javascript/packages/common/promise.ts:812 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"}