Repository: typeorm/typeorm
File: src/driver/cockroachdb/CockroachQueryRunner.ts (TypeScript)

Code before:

        this.storeQueries = true

        await this.broadcaster.broadcast("AfterTransactionStart")
    }

    /**
     * Commits transaction.
     * Error will be thrown if transaction was not started.
     */
    async commitTransaction(): Promise<void> {
        if (!this.isTransactionActive) throw new TransactionNotStartedError()

        await this.broadcaster.broadcast("BeforeTransactionCommit")

        if (this.transactionDepth > 1) {
            this.transactionDepth -= 1
            await this.query(
                `RELEASE SAVEPOINT typeorm_${this.transactionDepth}`,
            )
        } else {
            this.storeQueries = false
            this.transactionDepth -= 1
            // await this.query("RELEASE SAVEPOINT cockroach_restart")
            await this.query("COMMIT")
            this.queries = []
            this.isTransactionActive = false
            this.transactionRetries = 0
        }

        await this.broadcaster.broadcast("AfterTransactionCommit")
    }

    /**
     * Rollbacks transaction.
     * Error will be thrown if transaction was not started.
     */
    async rollbackTransaction(): Promise<void> {
        if (!this.isTransactionActive) throw new TransactionNotStartedError()

        await this.broadcaster.broadcast("BeforeTransactionRollback")

        if (this.transactionDepth > 1) {
            this.transactionDepth -= 1
            await this.query(
                `ROLLBACK TO SAVEPOINT typeorm_${this.transactionDepth}`,
            )
        } else {
            this.storeQueries = false
            this.transactionDepth -= 1
            await this.query("ROLLBACK")

Review comment (suggestion):
If we have some commented out code, I think we should include some explanation of why it is commented out, or just have it deleted altogether. 

Code after:

        this.storeQueries = true

        await this.broadcaster.broadcast("AfterTransactionStart")
    }

    /**
     * Commits transaction.
     * Error will be thrown if transaction was not started.
     */
    async commitTransaction(): Promise<void> {
        if (!this.isTransactionActive) throw new TransactionNotStartedError()

        await this.broadcaster.broadcast("BeforeTransactionCommit")

        if (this.transactionDepth > 1) {
            this.transactionDepth -= 1
            await this.query(
                `RELEASE SAVEPOINT typeorm_${this.transactionDepth}`,
            )
        } else {
            this.storeQueries = false
            this.transactionDepth -= 1
            // This was disabled because it failed tests after update to CRDB 24.2
            // https://github.com/typeorm/typeorm/pull/11190
            // await this.query("RELEASE SAVEPOINT cockroach_restart")
            await this.query("COMMIT")
            this.queries = []
            this.isTransactionActive = false
            this.transactionRetries = 0
        }

        await this.broadcaster.broadcast("AfterTransactionCommit")
    }

    /**
     * Rollbacks transaction.
     * Error will be thrown if transaction was not started.
     */
    async rollbackTransaction(): Promise<void> {
        if (!this.isTransactionActive) throw new TransactionNotStartedError()

        await this.broadcaster.broadcast("BeforeTransactionRollback")

        if (this.transactionDepth > 1) {
            this.transactionDepth -= 1
            await this.query(
                `ROLLBACK TO SAVEPOINT typeorm_${this.transactionDepth}`,
            )
        } else {
            this.storeQueries = false