@prisma/adapter-pg 6.16.0-dev.29 → 6.16.0-dev.30

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
@@ -690,17 +690,20 @@ var PgQueryable = class {
690
690
  }
691
691
  };
692
692
  var PgTransaction = class extends PgQueryable {
693
- constructor(client, options, pgOptions) {
693
+ constructor(client, options, pgOptions, cleanup) {
694
694
  super(client, pgOptions);
695
695
  this.options = options;
696
696
  this.pgOptions = pgOptions;
697
+ this.cleanup = cleanup;
697
698
  }
698
699
  async commit() {
699
700
  debug(`[js::commit]`);
701
+ this.cleanup?.();
700
702
  this.client.release();
701
703
  }
702
704
  async rollback() {
703
705
  debug(`[js::rollback]`);
706
+ this.cleanup?.();
704
707
  this.client.release();
705
708
  }
706
709
  };
@@ -717,12 +720,16 @@ var PrismaPgAdapter = class extends PgQueryable {
717
720
  const tag = "[js::startTransaction]";
718
721
  debug("%s options: %O", tag, options);
719
722
  const conn = await this.client.connect().catch((error) => this.onError(error));
720
- conn.on("error", (err) => {
723
+ const onError = (err) => {
721
724
  debug(`Error from pool connection: ${err.message} %O`, err);
722
725
  this.pgOptions?.onConnectionError?.(err);
723
- });
726
+ };
727
+ conn.on("error", onError);
728
+ const cleanup = () => {
729
+ conn.removeListener("error", onError);
730
+ };
724
731
  try {
725
- const tx = new PgTransaction(conn, options);
732
+ const tx = new PgTransaction(conn, options, this.pgOptions, cleanup);
726
733
  await tx.executeRaw({ sql: "BEGIN", args: [], argTypes: [] });
727
734
  if (isolationLevel) {
728
735
  await tx.executeRaw({
@@ -733,6 +740,7 @@ var PrismaPgAdapter = class extends PgQueryable {
733
740
  }
734
741
  return tx;
735
742
  } catch (error) {
743
+ cleanup();
736
744
  conn.release(error);
737
745
  this.onError(error);
738
746
  }
package/dist/index.mjs CHANGED
@@ -654,17 +654,20 @@ var PgQueryable = class {
654
654
  }
655
655
  };
656
656
  var PgTransaction = class extends PgQueryable {
657
- constructor(client, options, pgOptions) {
657
+ constructor(client, options, pgOptions, cleanup) {
658
658
  super(client, pgOptions);
659
659
  this.options = options;
660
660
  this.pgOptions = pgOptions;
661
+ this.cleanup = cleanup;
661
662
  }
662
663
  async commit() {
663
664
  debug(`[js::commit]`);
665
+ this.cleanup?.();
664
666
  this.client.release();
665
667
  }
666
668
  async rollback() {
667
669
  debug(`[js::rollback]`);
670
+ this.cleanup?.();
668
671
  this.client.release();
669
672
  }
670
673
  };
@@ -681,12 +684,16 @@ var PrismaPgAdapter = class extends PgQueryable {
681
684
  const tag = "[js::startTransaction]";
682
685
  debug("%s options: %O", tag, options);
683
686
  const conn = await this.client.connect().catch((error) => this.onError(error));
684
- conn.on("error", (err) => {
687
+ const onError = (err) => {
685
688
  debug(`Error from pool connection: ${err.message} %O`, err);
686
689
  this.pgOptions?.onConnectionError?.(err);
687
- });
690
+ };
691
+ conn.on("error", onError);
692
+ const cleanup = () => {
693
+ conn.removeListener("error", onError);
694
+ };
688
695
  try {
689
- const tx = new PgTransaction(conn, options);
696
+ const tx = new PgTransaction(conn, options, this.pgOptions, cleanup);
690
697
  await tx.executeRaw({ sql: "BEGIN", args: [], argTypes: [] });
691
698
  if (isolationLevel) {
692
699
  await tx.executeRaw({
@@ -697,6 +704,7 @@ var PrismaPgAdapter = class extends PgQueryable {
697
704
  }
698
705
  return tx;
699
706
  } catch (error) {
707
+ cleanup();
700
708
  conn.release(error);
701
709
  this.onError(error);
702
710
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/adapter-pg",
3
- "version": "6.16.0-dev.29",
3
+ "version": "6.16.0-dev.30",
4
4
  "description": "Prisma's driver adapter for \"pg\"",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -33,11 +33,11 @@
33
33
  "dependencies": {
34
34
  "postgres-array": "3.0.4",
35
35
  "pg": "^8.11.3",
36
- "@prisma/driver-adapter-utils": "6.16.0-dev.29"
36
+ "@prisma/driver-adapter-utils": "6.16.0-dev.30"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/pg": "8.11.11",
40
- "@prisma/debug": "6.16.0-dev.29"
40
+ "@prisma/debug": "6.16.0-dev.30"
41
41
  },
42
42
  "scripts": {
43
43
  "dev": "DEV=true tsx helpers/build.ts",