@prisma/adapter-pg 8.1.0-dev.11 → 8.1.0-dev.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -709,41 +709,38 @@ var PgTransaction = class extends PgQueryable {
709
709
  this.pgOptions = pgOptions;
710
710
  this.cleanup = cleanup;
711
711
  }
712
- settled = false;
713
- inFlightQueries = 0;
712
+ closed = false;
713
+ runningStatements = 0;
714
714
  async performIO(query) {
715
- if (this.settled) {
715
+ if (this.closed) {
716
716
  throw new import_driver_adapter_utils2.DriverAdapterError({
717
717
  kind: "TransactionAlreadyClosed",
718
718
  cause: "The transaction has already been committed or rolled back"
719
719
  });
720
720
  }
721
- this.inFlightQueries++;
721
+ this.runningStatements++;
722
722
  try {
723
723
  return await super.performIO(query);
724
724
  } finally {
725
- this.inFlightQueries--;
725
+ this.runningStatements--;
726
726
  }
727
727
  }
728
728
  /**
729
- * Settles the transaction at most once. The query engine can settle twice when
730
- * an interactive transaction timeout expires while COMMIT is in flight: the
731
- * abandoned commit chain and the compensating rollback both reach the adapter
732
- * (https://github.com/prisma/prisma/issues/29952). A second `release()` would
733
- * corrupt pg-pool's accounting once the pool has re-lent the client, so it is
734
- * skipped, and a client with statements still in flight is released with an
735
- * error so the pool destroys the connection instead of re-lending a busy one.
729
+ * Closes the transaction at most once. Once the pool has lent the client to
730
+ * a new owner, a second `release()` would corrupt the pool's bookkeeping, so
731
+ * it is skipped. A client with a statement still running is released with an
732
+ * error so the pool destroys it instead of lending out a busy connection.
736
733
  */
737
- settle() {
738
- if (this.settled) {
734
+ close() {
735
+ if (this.closed) {
739
736
  return;
740
737
  }
741
- this.settled = true;
738
+ this.closed = true;
742
739
  try {
743
740
  this.cleanup?.();
744
741
  } finally {
745
- if (this.inFlightQueries > 0) {
746
- this.client.release(new Error("Transaction settled with statements still in flight"));
742
+ if (this.runningStatements > 0) {
743
+ this.client.release(new Error("Transaction closed with a statement still running"));
747
744
  } else {
748
745
  this.client.release();
749
746
  }
@@ -751,11 +748,11 @@ var PgTransaction = class extends PgQueryable {
751
748
  }
752
749
  async commit() {
753
750
  debug(`[js::commit]`);
754
- this.settle();
751
+ this.close();
755
752
  }
756
753
  async rollback() {
757
754
  debug(`[js::rollback]`);
758
- this.settle();
755
+ this.close();
759
756
  }
760
757
  async createSavepoint(name2) {
761
758
  await this.executeRaw({ sql: `SAVEPOINT ${name2}`, args: [], argTypes: [] });
package/dist/index.mjs CHANGED
@@ -673,41 +673,38 @@ var PgTransaction = class extends PgQueryable {
673
673
  this.pgOptions = pgOptions;
674
674
  this.cleanup = cleanup;
675
675
  }
676
- settled = false;
677
- inFlightQueries = 0;
676
+ closed = false;
677
+ runningStatements = 0;
678
678
  async performIO(query) {
679
- if (this.settled) {
679
+ if (this.closed) {
680
680
  throw new DriverAdapterError({
681
681
  kind: "TransactionAlreadyClosed",
682
682
  cause: "The transaction has already been committed or rolled back"
683
683
  });
684
684
  }
685
- this.inFlightQueries++;
685
+ this.runningStatements++;
686
686
  try {
687
687
  return await super.performIO(query);
688
688
  } finally {
689
- this.inFlightQueries--;
689
+ this.runningStatements--;
690
690
  }
691
691
  }
692
692
  /**
693
- * Settles the transaction at most once. The query engine can settle twice when
694
- * an interactive transaction timeout expires while COMMIT is in flight: the
695
- * abandoned commit chain and the compensating rollback both reach the adapter
696
- * (https://github.com/prisma/prisma/issues/29952). A second `release()` would
697
- * corrupt pg-pool's accounting once the pool has re-lent the client, so it is
698
- * skipped, and a client with statements still in flight is released with an
699
- * error so the pool destroys the connection instead of re-lending a busy one.
693
+ * Closes the transaction at most once. Once the pool has lent the client to
694
+ * a new owner, a second `release()` would corrupt the pool's bookkeeping, so
695
+ * it is skipped. A client with a statement still running is released with an
696
+ * error so the pool destroys it instead of lending out a busy connection.
700
697
  */
701
- settle() {
702
- if (this.settled) {
698
+ close() {
699
+ if (this.closed) {
703
700
  return;
704
701
  }
705
- this.settled = true;
702
+ this.closed = true;
706
703
  try {
707
704
  this.cleanup?.();
708
705
  } finally {
709
- if (this.inFlightQueries > 0) {
710
- this.client.release(new Error("Transaction settled with statements still in flight"));
706
+ if (this.runningStatements > 0) {
707
+ this.client.release(new Error("Transaction closed with a statement still running"));
711
708
  } else {
712
709
  this.client.release();
713
710
  }
@@ -715,11 +712,11 @@ var PgTransaction = class extends PgQueryable {
715
712
  }
716
713
  async commit() {
717
714
  debug(`[js::commit]`);
718
- this.settle();
715
+ this.close();
719
716
  }
720
717
  async rollback() {
721
718
  debug(`[js::rollback]`);
722
- this.settle();
719
+ this.close();
723
720
  }
724
721
  async createSavepoint(name2) {
725
722
  await this.executeRaw({ sql: `SAVEPOINT ${name2}`, args: [], argTypes: [] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/adapter-pg",
3
- "version": "8.1.0-dev.11",
3
+ "version": "8.1.0-dev.12",
4
4
  "description": "Prisma's driver adapter for \"pg\"",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -34,10 +34,10 @@
34
34
  "pg": "^8.16.3",
35
35
  "postgres-array": "3.0.4",
36
36
  "@types/pg": "^8.16.0",
37
- "@prisma/driver-adapter-utils": "8.1.0-dev.11"
37
+ "@prisma/driver-adapter-utils": "8.1.0-dev.12"
38
38
  },
39
39
  "devDependencies": {
40
- "@prisma/debug": "8.1.0-dev.11"
40
+ "@prisma/debug": "8.1.0-dev.12"
41
41
  },
42
42
  "scripts": {
43
43
  "dev": "DEV=true tsx helpers/build.ts",