@prisma/query-plan-executor 7.10.0-dev.1 → 7.10.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.js +175 -86
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -22009,7 +22009,7 @@ var require_promise = __commonJS({
|
|
|
22009
22009
|
return Promise.reject(err);
|
|
22010
22010
|
}
|
|
22011
22011
|
};
|
|
22012
|
-
module2.exports.createPool = function
|
|
22012
|
+
module2.exports.createPool = function createPool3(opts) {
|
|
22013
22013
|
const options = new PoolOptions(opts);
|
|
22014
22014
|
const pool2 = new PoolPromise(options);
|
|
22015
22015
|
pool2.on("error", (err) => {
|
|
@@ -93473,7 +93473,7 @@ __export(index_exports, {
|
|
|
93473
93473
|
module.exports = __toCommonJS(index_exports);
|
|
93474
93474
|
|
|
93475
93475
|
// package.json
|
|
93476
|
-
var version = "7.10.0-dev.
|
|
93476
|
+
var version = "7.10.0-dev.11";
|
|
93477
93477
|
|
|
93478
93478
|
// ../../node_modules/.pnpm/temporal-polyfill@0.3.0/node_modules/temporal-polyfill/chunks/internal.js
|
|
93479
93479
|
function clampProp(e2, n2, t2, o2, r2) {
|
|
@@ -103579,6 +103579,14 @@ var InvalidTransactionIsolationLevelError = class extends TransactionManagerErro
|
|
|
103579
103579
|
}
|
|
103580
103580
|
};
|
|
103581
103581
|
var MAX_CLOSED_TRANSACTIONS = 100;
|
|
103582
|
+
var CANCEL_ROLLBACK_GRACE_MS = 2e3;
|
|
103583
|
+
function trackStartingTransaction() {
|
|
103584
|
+
let markSettled;
|
|
103585
|
+
const settled = new Promise((resolve) => {
|
|
103586
|
+
markSettled = resolve;
|
|
103587
|
+
});
|
|
103588
|
+
return { abortController: new AbortController(), settled, markSettled };
|
|
103589
|
+
}
|
|
103582
103590
|
var debug3 = Debug("prisma:client:transactionManager");
|
|
103583
103591
|
var COMMIT_QUERY = () => ({ sql: "COMMIT", args: [], argTypes: [] });
|
|
103584
103592
|
var ROLLBACK_QUERY = () => ({ sql: "ROLLBACK", args: [], argTypes: [] });
|
|
@@ -103598,6 +103606,9 @@ var TransactionManager = class {
|
|
|
103598
103606
|
// List of last closed transactions. Max MAX_CLOSED_TRANSACTIONS entries.
|
|
103599
103607
|
// Used to provide better error messages than a generic "transaction not found".
|
|
103600
103608
|
closedTransactions = [];
|
|
103609
|
+
// Transactions that are still being started. Tracked separately so that
|
|
103610
|
+
// `cancelAllTransactions` can reach them: they are not in `transactions` yet.
|
|
103611
|
+
#startingTransactions = /* @__PURE__ */ new Set();
|
|
103601
103612
|
driverAdapter;
|
|
103602
103613
|
transactionOptions;
|
|
103603
103614
|
tracingHelper;
|
|
@@ -103661,56 +103672,91 @@ var TransactionManager = class {
|
|
|
103661
103672
|
return { id: existing.id };
|
|
103662
103673
|
});
|
|
103663
103674
|
}
|
|
103664
|
-
const
|
|
103665
|
-
|
|
103666
|
-
|
|
103667
|
-
|
|
103668
|
-
|
|
103669
|
-
|
|
103670
|
-
|
|
103671
|
-
|
|
103672
|
-
|
|
103673
|
-
|
|
103674
|
-
|
|
103675
|
-
|
|
103676
|
-
|
|
103677
|
-
|
|
103678
|
-
|
|
103679
|
-
|
|
103680
|
-
|
|
103681
|
-
|
|
103682
|
-
|
|
103683
|
-
|
|
103684
|
-
|
|
103685
|
-
|
|
103686
|
-
|
|
103687
|
-
|
|
103688
|
-
|
|
103689
|
-
|
|
103690
|
-
|
|
103691
|
-
|
|
103692
|
-
|
|
103693
|
-
|
|
103694
|
-
|
|
103695
|
-
|
|
103696
|
-
|
|
103697
|
-
|
|
103698
|
-
|
|
103699
|
-
|
|
103700
|
-
|
|
103701
|
-
|
|
103702
|
-
|
|
103703
|
-
|
|
103704
|
-
|
|
103705
|
-
|
|
103706
|
-
|
|
103707
|
-
|
|
103708
|
-
|
|
103709
|
-
|
|
103710
|
-
|
|
103711
|
-
|
|
103712
|
-
|
|
103713
|
-
|
|
103675
|
+
const starting = trackStartingTransaction();
|
|
103676
|
+
const { abortController } = starting;
|
|
103677
|
+
this.#startingTransactions.add(starting);
|
|
103678
|
+
let discarding;
|
|
103679
|
+
try {
|
|
103680
|
+
const transaction = {
|
|
103681
|
+
id: await randomUUID(),
|
|
103682
|
+
status: "waiting",
|
|
103683
|
+
timer: void 0,
|
|
103684
|
+
timeout: options.timeout,
|
|
103685
|
+
startedAt: Date.now(),
|
|
103686
|
+
transaction: void 0,
|
|
103687
|
+
operationQueue: Promise.resolve(),
|
|
103688
|
+
depth: 1,
|
|
103689
|
+
savepoints: [],
|
|
103690
|
+
savepointCounter: 0
|
|
103691
|
+
};
|
|
103692
|
+
if (abortController.signal.aborted) {
|
|
103693
|
+
throw new TransactionStartTimeoutError();
|
|
103694
|
+
}
|
|
103695
|
+
const startTimer = createTimeoutIfDefined(() => abortController.abort(), options.maxWait);
|
|
103696
|
+
startTimer?.unref?.();
|
|
103697
|
+
const startTransactionPromise = this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
|
|
103698
|
+
transaction.transaction = await Promise.race([
|
|
103699
|
+
startTransactionPromise.finally(() => clearTimeout(startTimer)),
|
|
103700
|
+
once(abortController.signal, "abort").then(() => void 0)
|
|
103701
|
+
]);
|
|
103702
|
+
this.transactions.set(transaction.id, transaction);
|
|
103703
|
+
switch (transaction.status) {
|
|
103704
|
+
case "waiting":
|
|
103705
|
+
if (abortController.signal.aborted) {
|
|
103706
|
+
transaction.transaction = void 0;
|
|
103707
|
+
discarding = this.#discardStartedTransaction(startTransactionPromise);
|
|
103708
|
+
await this.#closeTransaction(transaction, "timed_out");
|
|
103709
|
+
throw new TransactionStartTimeoutError();
|
|
103710
|
+
}
|
|
103711
|
+
transaction.status = "running";
|
|
103712
|
+
transaction.startedAt = Date.now();
|
|
103713
|
+
transaction.timer = this.#startTransactionTimeout(transaction.id, options.timeout);
|
|
103714
|
+
return { id: transaction.id };
|
|
103715
|
+
case "timed_out":
|
|
103716
|
+
case "running":
|
|
103717
|
+
case "committed":
|
|
103718
|
+
case "rolled_back":
|
|
103719
|
+
throw new TransactionInternalConsistencyError(
|
|
103720
|
+
`Transaction in invalid state ${transaction.status} although it just finished startup.`
|
|
103721
|
+
);
|
|
103722
|
+
default:
|
|
103723
|
+
return assertNever(transaction["status"], "Unknown transaction status.");
|
|
103724
|
+
}
|
|
103725
|
+
} finally {
|
|
103726
|
+
this.#startingTransactions.delete(starting);
|
|
103727
|
+
if (discarding) {
|
|
103728
|
+
void discarding.finally(starting.markSettled);
|
|
103729
|
+
} else {
|
|
103730
|
+
starting.markSettled();
|
|
103731
|
+
}
|
|
103732
|
+
}
|
|
103733
|
+
}
|
|
103734
|
+
/**
|
|
103735
|
+
* Rolls back a transaction whose start was abandoned, and releases its connection.
|
|
103736
|
+
*
|
|
103737
|
+
* The `startTransaction` promise may still be running in the background. If it eventually
|
|
103738
|
+
* succeeds, we need to roll back and release the connection to avoid leaking it and
|
|
103739
|
+
* exhausting the connection pool. For adapters that don't use phantom queries (e.g. pg/neon),
|
|
103740
|
+
* `rollback()` only releases the connection without sending SQL, so we send an explicit
|
|
103741
|
+
* ROLLBACK first; otherwise the connection returns to the pool mid-transaction because
|
|
103742
|
+
* `BEGIN` already ran on the wire during startup.
|
|
103743
|
+
*
|
|
103744
|
+
* Errors are only logged: the caller has already reported the failure that led here.
|
|
103745
|
+
*/
|
|
103746
|
+
async #discardStartedTransaction(startTransactionPromise) {
|
|
103747
|
+
try {
|
|
103748
|
+
const tx = await startTransactionPromise;
|
|
103749
|
+
if (tx.options.usePhantomQuery) {
|
|
103750
|
+
await tx.rollback();
|
|
103751
|
+
} else {
|
|
103752
|
+
try {
|
|
103753
|
+
await tx.executeRaw(ROLLBACK_QUERY());
|
|
103754
|
+
} finally {
|
|
103755
|
+
await tx.rollback();
|
|
103756
|
+
}
|
|
103757
|
+
}
|
|
103758
|
+
} catch (e2) {
|
|
103759
|
+
debug3("error in discarded transaction:", e2);
|
|
103714
103760
|
}
|
|
103715
103761
|
}
|
|
103716
103762
|
async commitTransaction(transactionId) {
|
|
@@ -103801,16 +103847,21 @@ var TransactionManager = class {
|
|
|
103801
103847
|
return transaction;
|
|
103802
103848
|
}
|
|
103803
103849
|
async cancelAllTransactions() {
|
|
103804
|
-
|
|
103805
|
-
|
|
103850
|
+
const starting = [...this.#startingTransactions];
|
|
103851
|
+
for (const { abortController } of starting) {
|
|
103852
|
+
abortController.abort();
|
|
103853
|
+
}
|
|
103854
|
+
await Promise.allSettled([
|
|
103855
|
+
...[...this.transactions.values()].map(
|
|
103806
103856
|
(tx) => this.#runSerialized(tx, async () => {
|
|
103807
103857
|
const current = this.transactions.get(tx.id);
|
|
103808
103858
|
if (current) {
|
|
103809
103859
|
await this.#closeTransaction(current, "rolled_back");
|
|
103810
103860
|
}
|
|
103811
103861
|
})
|
|
103812
|
-
)
|
|
103813
|
-
|
|
103862
|
+
),
|
|
103863
|
+
...starting.map(({ settled }) => settleWithin(settled, CANCEL_ROLLBACK_GRACE_MS))
|
|
103864
|
+
]);
|
|
103814
103865
|
}
|
|
103815
103866
|
#nextSavepointName(transaction) {
|
|
103816
103867
|
return `prisma_sp_${transaction.savepointCounter++}`;
|
|
@@ -103963,6 +104014,14 @@ var TransactionManager = class {
|
|
|
103963
104014
|
function createTimeoutIfDefined(cb, ms) {
|
|
103964
104015
|
return ms !== void 0 ? setTimeout(cb, ms) : void 0;
|
|
103965
104016
|
}
|
|
104017
|
+
function settleWithin(promise2, timeout) {
|
|
104018
|
+
let timer;
|
|
104019
|
+
const deadline = new Promise((resolve) => {
|
|
104020
|
+
timer = setTimeout(resolve, timeout);
|
|
104021
|
+
timer?.unref?.();
|
|
104022
|
+
});
|
|
104023
|
+
return Promise.race([promise2, deadline]).finally(() => clearTimeout(timer));
|
|
104024
|
+
}
|
|
103966
104025
|
|
|
103967
104026
|
// ../../node_modules/.pnpm/hono@4.12.23/node_modules/hono/dist/compose.js
|
|
103968
104027
|
var compose = (middleware, onError, onNotFound) => {
|
|
@@ -106490,10 +106549,11 @@ var MariaDbTransaction = class extends MariaDbQueryable {
|
|
|
106490
106549
|
}
|
|
106491
106550
|
};
|
|
106492
106551
|
var PrismaMariaDbAdapter = class extends MariaDbQueryable {
|
|
106493
|
-
constructor(client, capabilities, mariadbOptions) {
|
|
106552
|
+
constructor(client, capabilities, mariadbOptions, release) {
|
|
106494
106553
|
super(client, mariadbOptions);
|
|
106495
106554
|
this.capabilities = capabilities;
|
|
106496
106555
|
this.mariadbOptions = mariadbOptions;
|
|
106556
|
+
this.release = release;
|
|
106497
106557
|
}
|
|
106498
106558
|
executeScript(_script) {
|
|
106499
106559
|
throw new Error("Not implemented yet");
|
|
@@ -106537,7 +106597,7 @@ var PrismaMariaDbAdapter = class extends MariaDbQueryable {
|
|
|
106537
106597
|
}
|
|
106538
106598
|
}
|
|
106539
106599
|
async dispose() {
|
|
106540
|
-
|
|
106600
|
+
return this.release?.();
|
|
106541
106601
|
}
|
|
106542
106602
|
underlyingDriver() {
|
|
106543
106603
|
return this.client;
|
|
@@ -106547,47 +106607,73 @@ var PrismaMariaDbAdapterFactory = class {
|
|
|
106547
106607
|
provider = "mysql";
|
|
106548
106608
|
adapterName = name;
|
|
106549
106609
|
#capabilities;
|
|
106550
|
-
#
|
|
106610
|
+
#poolOrConfig;
|
|
106551
106611
|
#options;
|
|
106552
|
-
|
|
106553
|
-
|
|
106554
|
-
|
|
106555
|
-
|
|
106556
|
-
|
|
106557
|
-
|
|
106558
|
-
|
|
106559
|
-
|
|
106560
|
-
} catch (error44) {
|
|
106561
|
-
debug4("Error parsing connection string: %O", error44);
|
|
106562
|
-
this.#config = config3;
|
|
106563
|
-
}
|
|
106564
|
-
} else {
|
|
106565
|
-
if (config3.prepareCacheLength === void 0) {
|
|
106566
|
-
this.#config = { ...config3, prepareCacheLength: 0 };
|
|
106567
|
-
} else {
|
|
106568
|
-
this.#config = config3;
|
|
106569
|
-
}
|
|
106570
|
-
}
|
|
106612
|
+
#externalPoolClaimed = false;
|
|
106613
|
+
/**
|
|
106614
|
+
* Accepts either connection settings for a pool the adapter creates and owns, or an existing
|
|
106615
|
+
* pool. Settings the adapter would normally apply to its own pool (such as defaulting
|
|
106616
|
+
* `prepareCacheLength` to 0) are not applied to an externally created pool.
|
|
106617
|
+
*/
|
|
106618
|
+
constructor(poolOrConfig, options) {
|
|
106619
|
+
this.#poolOrConfig = isPool(poolOrConfig) ? { type: "pool", pool: poolOrConfig } : { type: "config", config: normalizeConfig(poolOrConfig) };
|
|
106571
106620
|
this.#options = options;
|
|
106572
106621
|
}
|
|
106573
106622
|
async connect() {
|
|
106574
|
-
|
|
106575
|
-
|
|
106576
|
-
|
|
106577
|
-
|
|
106578
|
-
if (error44 instanceof Error && error44.message.startsWith("error parsing connection string")) {
|
|
106623
|
+
const poolOrConfig = this.#poolOrConfig;
|
|
106624
|
+
const ownsPool = poolOrConfig.type === "config" || this.#options?.disposeExternalPool === true;
|
|
106625
|
+
if (poolOrConfig.type === "pool" && ownsPool) {
|
|
106626
|
+
if (this.#externalPoolClaimed) {
|
|
106579
106627
|
throw new Error(
|
|
106580
|
-
"
|
|
106628
|
+
"connect() can only be called once when `disposeExternalPool` is true, because the adapter ends the pool it was given and cannot create a replacement from it. Either pass connection settings instead of a pool, or set `disposeExternalPool: false` and end the pool yourself once you no longer need the adapter."
|
|
106581
106629
|
);
|
|
106582
106630
|
}
|
|
106583
|
-
|
|
106631
|
+
this.#externalPoolClaimed = true;
|
|
106584
106632
|
}
|
|
106633
|
+
const pool2 = poolOrConfig.type === "pool" ? poolOrConfig.pool : createPool2(poolOrConfig.config);
|
|
106585
106634
|
if (this.#capabilities === void 0) {
|
|
106586
106635
|
this.#capabilities = await getCapabilities(pool2);
|
|
106587
106636
|
}
|
|
106588
|
-
return new PrismaMariaDbAdapter(pool2, this.#capabilities, this.#options)
|
|
106637
|
+
return new PrismaMariaDbAdapter(pool2, this.#capabilities, this.#options, async () => {
|
|
106638
|
+
if (ownsPool) {
|
|
106639
|
+
await pool2.end();
|
|
106640
|
+
}
|
|
106641
|
+
});
|
|
106589
106642
|
}
|
|
106590
106643
|
};
|
|
106644
|
+
function isPool(poolOrConfig) {
|
|
106645
|
+
return typeof poolOrConfig === "object" && typeof poolOrConfig.getConnection === "function";
|
|
106646
|
+
}
|
|
106647
|
+
function normalizeConfig(config3) {
|
|
106648
|
+
if (typeof config3 === "string") {
|
|
106649
|
+
try {
|
|
106650
|
+
const url2 = new URL(config3);
|
|
106651
|
+
if (!url2.searchParams.has("prepareCacheLength")) {
|
|
106652
|
+
url2.searchParams.set("prepareCacheLength", "0");
|
|
106653
|
+
}
|
|
106654
|
+
return rewriteConnectionString(url2).toString();
|
|
106655
|
+
} catch {
|
|
106656
|
+
debug4("Failed to parse the connection string, passing it to the driver as-is");
|
|
106657
|
+
return config3;
|
|
106658
|
+
}
|
|
106659
|
+
}
|
|
106660
|
+
if (config3.prepareCacheLength === void 0) {
|
|
106661
|
+
return { ...config3, prepareCacheLength: 0 };
|
|
106662
|
+
}
|
|
106663
|
+
return config3;
|
|
106664
|
+
}
|
|
106665
|
+
function createPool2(config3) {
|
|
106666
|
+
try {
|
|
106667
|
+
return mariadb.createPool(config3);
|
|
106668
|
+
} catch (error44) {
|
|
106669
|
+
if (error44 instanceof Error && error44.message.startsWith("error parsing connection string")) {
|
|
106670
|
+
throw new Error(
|
|
106671
|
+
"error parsing connection string, format must be 'mariadb://[<user>[:<password>]@]<host>[:<port>]/[<db>[?<opt1>=<value1>[&<opt2>=<value2>]]]'"
|
|
106672
|
+
);
|
|
106673
|
+
}
|
|
106674
|
+
throw error44;
|
|
106675
|
+
}
|
|
106676
|
+
}
|
|
106591
106677
|
async function getCapabilities(pool2) {
|
|
106592
106678
|
const tag2 = "[js::getCapabilities]";
|
|
106593
106679
|
try {
|
|
@@ -106619,6 +106705,9 @@ function rewriteConnectionString(url2) {
|
|
|
106619
106705
|
if (url2.protocol === "mysql:") {
|
|
106620
106706
|
url2.protocol = "mariadb:";
|
|
106621
106707
|
}
|
|
106708
|
+
if (url2.hostname.startsWith("[") && url2.hostname.endsWith("]")) {
|
|
106709
|
+
url2.hostname = encodeURIComponent(url2.hostname.slice(1, -1));
|
|
106710
|
+
}
|
|
106622
106711
|
return url2;
|
|
106623
106712
|
}
|
|
106624
106713
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/query-plan-executor",
|
|
3
|
-
"version": "7.10.0-dev.
|
|
3
|
+
"version": "7.10.0-dev.11",
|
|
4
4
|
"description": "This package is intended for Prisma's internal use",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"hono": "^4.12.23",
|
|
20
20
|
"temporal-polyfill": "0.3.0",
|
|
21
21
|
"zod": "4.1.3",
|
|
22
|
-
"@prisma/adapter-
|
|
23
|
-
"@prisma/
|
|
24
|
-
"@prisma/
|
|
25
|
-
"@prisma/
|
|
26
|
-
"@prisma/adapter-
|
|
22
|
+
"@prisma/adapter-pg": "7.10.0-dev.11",
|
|
23
|
+
"@prisma/client-engine-runtime": "7.10.0-dev.11",
|
|
24
|
+
"@prisma/adapter-mssql": "7.10.0-dev.11",
|
|
25
|
+
"@prisma/adapter-mariadb": "7.10.0-dev.11",
|
|
26
|
+
"@prisma/driver-adapter-utils": "7.10.0-dev.11"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"dist"
|