@prisma/adapter-pg 8.1.0-dev.1 → 8.1.0-dev.11
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +42 -4
- package/dist/index.mjs +42 -4
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -29,7 +29,7 @@ declare class PgQueryable<ClientT extends StdClient | TransactionClient> impleme
|
|
|
29
29
|
* Should the query fail due to a connection error, the connection is
|
|
30
30
|
* marked as unhealthy.
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
protected performIO(query: SqlQuery): Promise<pg.QueryArrayResult<any>>;
|
|
33
33
|
protected onError(error: unknown): never;
|
|
34
34
|
}
|
|
35
35
|
|
package/dist/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ declare class PgQueryable<ClientT extends StdClient | TransactionClient> impleme
|
|
|
29
29
|
* Should the query fail due to a connection error, the connection is
|
|
30
30
|
* marked as unhealthy.
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
protected performIO(query: SqlQuery): Promise<pg.QueryArrayResult<any>>;
|
|
33
33
|
protected onError(error: unknown): never;
|
|
34
34
|
}
|
|
35
35
|
|
package/dist/index.js
CHANGED
|
@@ -709,15 +709,53 @@ var PgTransaction = class extends PgQueryable {
|
|
|
709
709
|
this.pgOptions = pgOptions;
|
|
710
710
|
this.cleanup = cleanup;
|
|
711
711
|
}
|
|
712
|
+
settled = false;
|
|
713
|
+
inFlightQueries = 0;
|
|
714
|
+
async performIO(query) {
|
|
715
|
+
if (this.settled) {
|
|
716
|
+
throw new import_driver_adapter_utils2.DriverAdapterError({
|
|
717
|
+
kind: "TransactionAlreadyClosed",
|
|
718
|
+
cause: "The transaction has already been committed or rolled back"
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
this.inFlightQueries++;
|
|
722
|
+
try {
|
|
723
|
+
return await super.performIO(query);
|
|
724
|
+
} finally {
|
|
725
|
+
this.inFlightQueries--;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
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.
|
|
736
|
+
*/
|
|
737
|
+
settle() {
|
|
738
|
+
if (this.settled) {
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
this.settled = true;
|
|
742
|
+
try {
|
|
743
|
+
this.cleanup?.();
|
|
744
|
+
} finally {
|
|
745
|
+
if (this.inFlightQueries > 0) {
|
|
746
|
+
this.client.release(new Error("Transaction settled with statements still in flight"));
|
|
747
|
+
} else {
|
|
748
|
+
this.client.release();
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
712
752
|
async commit() {
|
|
713
753
|
debug(`[js::commit]`);
|
|
714
|
-
this.
|
|
715
|
-
this.client.release();
|
|
754
|
+
this.settle();
|
|
716
755
|
}
|
|
717
756
|
async rollback() {
|
|
718
757
|
debug(`[js::rollback]`);
|
|
719
|
-
this.
|
|
720
|
-
this.client.release();
|
|
758
|
+
this.settle();
|
|
721
759
|
}
|
|
722
760
|
async createSavepoint(name2) {
|
|
723
761
|
await this.executeRaw({ sql: `SAVEPOINT ${name2}`, args: [], argTypes: [] });
|
package/dist/index.mjs
CHANGED
|
@@ -673,15 +673,53 @@ var PgTransaction = class extends PgQueryable {
|
|
|
673
673
|
this.pgOptions = pgOptions;
|
|
674
674
|
this.cleanup = cleanup;
|
|
675
675
|
}
|
|
676
|
+
settled = false;
|
|
677
|
+
inFlightQueries = 0;
|
|
678
|
+
async performIO(query) {
|
|
679
|
+
if (this.settled) {
|
|
680
|
+
throw new DriverAdapterError({
|
|
681
|
+
kind: "TransactionAlreadyClosed",
|
|
682
|
+
cause: "The transaction has already been committed or rolled back"
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
this.inFlightQueries++;
|
|
686
|
+
try {
|
|
687
|
+
return await super.performIO(query);
|
|
688
|
+
} finally {
|
|
689
|
+
this.inFlightQueries--;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
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.
|
|
700
|
+
*/
|
|
701
|
+
settle() {
|
|
702
|
+
if (this.settled) {
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
this.settled = true;
|
|
706
|
+
try {
|
|
707
|
+
this.cleanup?.();
|
|
708
|
+
} finally {
|
|
709
|
+
if (this.inFlightQueries > 0) {
|
|
710
|
+
this.client.release(new Error("Transaction settled with statements still in flight"));
|
|
711
|
+
} else {
|
|
712
|
+
this.client.release();
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
676
716
|
async commit() {
|
|
677
717
|
debug(`[js::commit]`);
|
|
678
|
-
this.
|
|
679
|
-
this.client.release();
|
|
718
|
+
this.settle();
|
|
680
719
|
}
|
|
681
720
|
async rollback() {
|
|
682
721
|
debug(`[js::rollback]`);
|
|
683
|
-
this.
|
|
684
|
-
this.client.release();
|
|
722
|
+
this.settle();
|
|
685
723
|
}
|
|
686
724
|
async createSavepoint(name2) {
|
|
687
725
|
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.
|
|
3
|
+
"version": "8.1.0-dev.11",
|
|
4
4
|
"description": "Prisma's driver adapter for \"pg\"",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "https://github.com/prisma/
|
|
22
|
+
"url": "https://github.com/prisma/orm.git",
|
|
23
23
|
"directory": "packages/adapter-pg"
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
@@ -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.
|
|
37
|
+
"@prisma/driver-adapter-utils": "8.1.0-dev.11"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@prisma/debug": "8.1.0-dev.
|
|
40
|
+
"@prisma/debug": "8.1.0-dev.11"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"dev": "DEV=true tsx helpers/build.ts",
|