@prisma/adapter-neon 6.18.0-dev.7 → 6.18.0-dev.9

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
@@ -593,16 +593,19 @@ var NeonWsQueryable = class extends NeonQueryable {
593
593
  }
594
594
  };
595
595
  var NeonTransaction = class extends NeonWsQueryable {
596
- constructor(client, options) {
596
+ constructor(client, options, cleanup) {
597
597
  super(client);
598
598
  this.options = options;
599
+ this.cleanup = cleanup;
599
600
  }
600
601
  async commit() {
601
602
  debug(`[js::commit]`);
603
+ this.cleanup?.();
602
604
  this.client.release();
603
605
  }
604
606
  async rollback() {
605
607
  debug(`[js::rollback]`);
608
+ this.cleanup?.();
606
609
  this.client.release();
607
610
  }
608
611
  };
@@ -622,12 +625,16 @@ var PrismaNeonAdapter = class extends NeonWsQueryable {
622
625
  const tag = "[js::startTransaction]";
623
626
  debug("%s options: %O", tag, options);
624
627
  const conn = await this.client.connect().catch((error) => this.onError(error));
625
- conn.on("error", (err) => {
628
+ const onError = (err) => {
626
629
  debug(`Error from pool connection: ${err.message} %O`, err);
627
630
  this.options?.onConnectionError?.(err);
628
- });
631
+ };
632
+ conn.on("error", onError);
633
+ const cleanup = () => {
634
+ conn.removeListener("error", onError);
635
+ };
629
636
  try {
630
- const tx = new NeonTransaction(conn, options);
637
+ const tx = new NeonTransaction(conn, options, cleanup);
631
638
  await tx.executeRaw({ sql: "BEGIN", args: [], argTypes: [] });
632
639
  if (isolationLevel) {
633
640
  await tx.executeRaw({
@@ -638,6 +645,7 @@ var PrismaNeonAdapter = class extends NeonWsQueryable {
638
645
  }
639
646
  return tx;
640
647
  } catch (error) {
648
+ cleanup();
641
649
  conn.release(error);
642
650
  this.onError(error);
643
651
  }
package/dist/index.mjs CHANGED
@@ -556,16 +556,19 @@ var NeonWsQueryable = class extends NeonQueryable {
556
556
  }
557
557
  };
558
558
  var NeonTransaction = class extends NeonWsQueryable {
559
- constructor(client, options) {
559
+ constructor(client, options, cleanup) {
560
560
  super(client);
561
561
  this.options = options;
562
+ this.cleanup = cleanup;
562
563
  }
563
564
  async commit() {
564
565
  debug(`[js::commit]`);
566
+ this.cleanup?.();
565
567
  this.client.release();
566
568
  }
567
569
  async rollback() {
568
570
  debug(`[js::rollback]`);
571
+ this.cleanup?.();
569
572
  this.client.release();
570
573
  }
571
574
  };
@@ -585,12 +588,16 @@ var PrismaNeonAdapter = class extends NeonWsQueryable {
585
588
  const tag = "[js::startTransaction]";
586
589
  debug("%s options: %O", tag, options);
587
590
  const conn = await this.client.connect().catch((error) => this.onError(error));
588
- conn.on("error", (err) => {
591
+ const onError = (err) => {
589
592
  debug(`Error from pool connection: ${err.message} %O`, err);
590
593
  this.options?.onConnectionError?.(err);
591
- });
594
+ };
595
+ conn.on("error", onError);
596
+ const cleanup = () => {
597
+ conn.removeListener("error", onError);
598
+ };
592
599
  try {
593
- const tx = new NeonTransaction(conn, options);
600
+ const tx = new NeonTransaction(conn, options, cleanup);
594
601
  await tx.executeRaw({ sql: "BEGIN", args: [], argTypes: [] });
595
602
  if (isolationLevel) {
596
603
  await tx.executeRaw({
@@ -601,6 +608,7 @@ var PrismaNeonAdapter = class extends NeonWsQueryable {
601
608
  }
602
609
  return tx;
603
610
  } catch (error) {
611
+ cleanup();
604
612
  conn.release(error);
605
613
  this.onError(error);
606
614
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/adapter-neon",
3
- "version": "6.18.0-dev.7",
3
+ "version": "6.18.0-dev.9",
4
4
  "description": "Prisma's driver adapter for \"@neondatabase/serverless\"",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -33,10 +33,14 @@
33
33
  "dependencies": {
34
34
  "postgres-array": "3.0.4",
35
35
  "@neondatabase/serverless": ">0.6.0 <2",
36
- "@prisma/driver-adapter-utils": "6.18.0-dev.7"
36
+ "@prisma/driver-adapter-utils": "6.18.0-dev.9"
37
+ },
38
+ "devDependencies": {
39
+ "@prisma/debug": "6.18.0-dev.9"
37
40
  },
38
41
  "scripts": {
39
42
  "dev": "DEV=true tsx helpers/build.ts",
40
- "build": "tsx helpers/build.ts"
43
+ "build": "tsx helpers/build.ts",
44
+ "test": "vitest run"
41
45
  }
42
46
  }