@prisma/query-plan-executor 6.18.0-dev.2 → 6.18.0-dev.4

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.ts CHANGED
@@ -5135,6 +5135,12 @@ export declare class TransactionManager {
5135
5135
  onQuery?: (event: QueryEvent) => void;
5136
5136
  provider?: SchemaProvider;
5137
5137
  });
5138
+ /**
5139
+ * Starts an internal transaction. The difference to `startTransaction` is that it does not
5140
+ * use the default transaction options from the `TransactionManager`, which in practice means
5141
+ * that it does not apply the default timeouts.
5142
+ */
5143
+ startInternalTransaction(options?: TransactionOptions_2): Promise<TransactionInfo>;
5138
5144
  startTransaction(options?: TransactionOptions_2): Promise<TransactionInfo>;
5139
5145
  commitTransaction(transactionId: string): Promise<void>;
5140
5146
  rollbackTransaction(transactionId: string): Promise<void>;
package/dist/index.js CHANGED
@@ -107054,7 +107054,7 @@ var QueryInterpreter = class _QueryInterpreter {
107054
107054
  return this.interpretNode(node.args, queryable, scope, generators);
107055
107055
  }
107056
107056
  const transactionManager = this.#transactionManager.manager;
107057
- const transactionInfo = await transactionManager.startTransaction();
107057
+ const transactionInfo = await transactionManager.startInternalTransaction();
107058
107058
  const transaction = await transactionManager.getTransaction(transactionInfo, "query");
107059
107059
  try {
107060
107060
  const value = await this.interpretNode(node.args, transaction, scope, generators);
@@ -107344,24 +107344,39 @@ var TransactionManager = class {
107344
107344
  this.#onQuery = onQuery;
107345
107345
  this.#provider = provider;
107346
107346
  }
107347
+ /**
107348
+ * Starts an internal transaction. The difference to `startTransaction` is that it does not
107349
+ * use the default transaction options from the `TransactionManager`, which in practice means
107350
+ * that it does not apply the default timeouts.
107351
+ */
107352
+ async startInternalTransaction(options) {
107353
+ const validatedOptions = options !== void 0 ? this.#validateOptions(options) : {};
107354
+ return await this.tracingHelper.runInChildSpan(
107355
+ "start_transaction",
107356
+ () => this.#startTransactionImpl(validatedOptions)
107357
+ );
107358
+ }
107347
107359
  async startTransaction(options) {
107348
- return await this.tracingHelper.runInChildSpan("start_transaction", () => this.#startTransactionImpl(options));
107360
+ const validatedOptions = options !== void 0 ? this.#validateOptions(options) : this.transactionOptions;
107361
+ return await this.tracingHelper.runInChildSpan(
107362
+ "start_transaction",
107363
+ () => this.#startTransactionImpl(validatedOptions)
107364
+ );
107349
107365
  }
107350
107366
  async #startTransactionImpl(options) {
107351
- const validatedOptions = options !== void 0 ? this.#validateOptions(options) : this.transactionOptions;
107352
107367
  const transaction = {
107353
107368
  id: await randomUUID2(),
107354
107369
  status: "waiting",
107355
107370
  timer: void 0,
107356
- timeout: validatedOptions.timeout,
107371
+ timeout: options.timeout,
107357
107372
  startedAt: Date.now(),
107358
107373
  transaction: void 0
107359
107374
  };
107360
107375
  this.transactions.set(transaction.id, transaction);
107361
107376
  let hasTimedOut = false;
107362
- const startTimer = setTimeout(() => hasTimedOut = true, validatedOptions.maxWait);
107363
- startTimer.unref?.();
107364
- transaction.transaction = await this.driverAdapter.startTransaction(validatedOptions.isolationLevel).catch(rethrowAsUserFacing);
107377
+ const startTimer = createTimeoutIfDefined(() => hasTimedOut = true, options.maxWait);
107378
+ startTimer?.unref?.();
107379
+ transaction.transaction = await this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
107365
107380
  clearTimeout(startTimer);
107366
107381
  switch (transaction.status) {
107367
107382
  case "waiting":
@@ -107370,7 +107385,7 @@ var TransactionManager = class {
107370
107385
  throw new TransactionStartTimeoutError();
107371
107386
  }
107372
107387
  transaction.status = "running";
107373
- transaction.timer = this.#startTransactionTimeout(transaction.id, validatedOptions.timeout);
107388
+ transaction.timer = this.#startTransactionTimeout(transaction.id, options.timeout);
107374
107389
  return { id: transaction.id };
107375
107390
  case "timed_out":
107376
107391
  case "running":
@@ -107440,7 +107455,7 @@ var TransactionManager = class {
107440
107455
  }
107441
107456
  #startTransactionTimeout(transactionId, timeout) {
107442
107457
  const timeoutStartedAt = Date.now();
107443
- const timer = setTimeout(async () => {
107458
+ const timer = createTimeoutIfDefined(async () => {
107444
107459
  debug3("Transaction timed out.", { transactionId, timeoutStartedAt, timeout });
107445
107460
  const tx = this.transactions.get(transactionId);
107446
107461
  if (tx && ["running", "waiting"].includes(tx.status)) {
@@ -107449,7 +107464,7 @@ var TransactionManager = class {
107449
107464
  debug3("Transaction already committed or rolled back when timeout happened.", transactionId);
107450
107465
  }
107451
107466
  }, timeout);
107452
- timer.unref?.();
107467
+ timer?.unref?.();
107453
107468
  return timer;
107454
107469
  }
107455
107470
  async #closeTransaction(tx, status) {
@@ -107519,6 +107534,9 @@ var TransactionManager = class {
107519
107534
  });
107520
107535
  }
107521
107536
  };
107537
+ function createTimeoutIfDefined(cb, ms) {
107538
+ return ms !== void 0 ? setTimeout(cb, ms) : void 0;
107539
+ }
107522
107540
 
107523
107541
  // ../../node_modules/.pnpm/hono@4.9.4/node_modules/hono/dist/compose.js
107524
107542
  var compose = (middleware, onError, onNotFound) => {
@@ -109092,7 +109110,7 @@ function isPromiseLike(value) {
109092
109110
  }
109093
109111
 
109094
109112
  // package.json
109095
- var version = "6.18.0-dev.2";
109113
+ var version = "6.18.0-dev.4";
109096
109114
 
109097
109115
  // src/utils/error.ts
109098
109116
  function extractErrorFromUnknown(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/query-plan-executor",
3
- "version": "6.18.0-dev.2",
3
+ "version": "6.18.0-dev.4",
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",
@@ -20,11 +20,11 @@
20
20
  "temporal-polyfill": "0.3.0",
21
21
  "vitest": "3.2.4",
22
22
  "zod": "4.1.3",
23
- "@prisma/adapter-pg": "6.18.0-dev.2",
24
- "@prisma/adapter-mariadb": "6.18.0-dev.2",
25
- "@prisma/adapter-mssql": "6.18.0-dev.2",
26
- "@prisma/driver-adapter-utils": "6.18.0-dev.2",
27
- "@prisma/client-engine-runtime": "6.18.0-dev.2"
23
+ "@prisma/adapter-pg": "6.18.0-dev.4",
24
+ "@prisma/adapter-mssql": "6.18.0-dev.4",
25
+ "@prisma/client-engine-runtime": "6.18.0-dev.4",
26
+ "@prisma/driver-adapter-utils": "6.18.0-dev.4",
27
+ "@prisma/adapter-mariadb": "6.18.0-dev.4"
28
28
  },
29
29
  "files": [
30
30
  "dist"