@prisma/orm-family-sql 8.0.0-rc.23-dev.14 → 8.0.0-rc.24-dev.1

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.
Files changed (79) hide show
  1. package/dist/{ast-CrnvUofJ.d.mts → ast-DGfphK4T.d.mts} +2 -2
  2. package/dist/{ast-CrnvUofJ.d.mts.map → ast-DGfphK4T.d.mts.map} +1 -1
  3. package/dist/builder.d.mts +3 -3
  4. package/dist/builder__runtime.d.mts +7 -7
  5. package/dist/builder__types.d.mts +5 -5
  6. package/dist/{collection-methods-p_bnn5LM-B8bdfRNR.d.mts → collection-methods-CvUwcmzf-BW0NhiB_.d.mts} +3 -3
  7. package/dist/{collection-methods-p_bnn5LM-B8bdfRNR.d.mts.map → collection-methods-CvUwcmzf-BW0NhiB_.d.mts.map} +1 -1
  8. package/dist/collection-methods-TTQfofph.d.mts +1 -0
  9. package/dist/{control-C0Jp0muh.d.mts → control-Bp3csZwm.d.mts} +5 -5
  10. package/dist/{control-C0Jp0muh.d.mts.map → control-Bp3csZwm.d.mts.map} +1 -1
  11. package/dist/{control-adapter-BfyLe7rh-0LQGA2VV.d.mts → control-adapter-BfyLe7rh-BzDhqiKl.d.mts} +3 -3
  12. package/dist/{control-adapter-BfyLe7rh-0LQGA2VV.d.mts.map → control-adapter-BfyLe7rh-BzDhqiKl.d.mts.map} +1 -1
  13. package/dist/{control-adapter-DMrjnUFj.d.mts → control-adapter-ltsPDa2r.d.mts} +2 -2
  14. package/dist/{control-adapter-DMrjnUFj.d.mts.map → control-adapter-ltsPDa2r.d.mts.map} +1 -1
  15. package/dist/{db-DfYeGVcu-NRittTYE.d.mts → db-DfYeGVcu-o1Z8rm-W.d.mts} +7 -7
  16. package/dist/{db-DfYeGVcu-NRittTYE.d.mts.map → db-DfYeGVcu-o1Z8rm-W.d.mts.map} +1 -1
  17. package/dist/{diff-BBEq2-E2.d.mts → diff-Br8rXGsH.d.mts} +2 -2
  18. package/dist/{diff-BBEq2-E2.d.mts.map → diff-Br8rXGsH.d.mts.map} +1 -1
  19. package/dist/{driver-types-Bobm0hWv-B9rTP8XQ.d.mts → driver-types-BpWfDb-T-DlmIXaYA.d.mts} +7 -4
  20. package/dist/driver-types-BpWfDb-T-DlmIXaYA.d.mts.map +1 -0
  21. package/dist/{exports-WNaGWaJR-C6wltYlN.mjs → exports-cGSgYmrd-BADpxA8G.mjs} +130 -47
  22. package/dist/exports-cGSgYmrd-BADpxA8G.mjs.map +1 -0
  23. package/dist/{expression-DmvKA8dE-D29cLTJG.d.mts → expression-67JiCQFK-DaVAG7yC.d.mts} +3 -3
  24. package/dist/{expression-DmvKA8dE-D29cLTJG.d.mts.map → expression-67JiCQFK-DaVAG7yC.d.mts.map} +1 -1
  25. package/dist/{expression-DSAx-7Ri-C4W_nQ6T.d.mts → expression-Ba92rPKp-DtfV_Whm.d.mts} +3 -3
  26. package/dist/expression-Ba92rPKp-DtfV_Whm.d.mts.map +1 -0
  27. package/dist/expression-D_ZePY3d.d.mts +2 -0
  28. package/dist/family.d.mts +6 -6
  29. package/dist/family__control-adapter.d.mts +2 -2
  30. package/dist/family__control.d.mts +2 -2
  31. package/dist/family__diff.d.mts +1 -1
  32. package/dist/family__migration.d.mts +1 -1
  33. package/dist/functions-D8u9_Jq4.d.mts +1 -0
  34. package/dist/{index-reference-2EXdtnBp-BxO97DG1.d.mts → index-reference-BG-nULu_-DqCWjexx.d.mts} +3 -3
  35. package/dist/{index-reference-2EXdtnBp-BxO97DG1.d.mts.map → index-reference-BG-nULu_-DqCWjexx.d.mts.map} +1 -1
  36. package/dist/index-reference-WLPSKxp9.d.mts +1 -0
  37. package/dist/{index-rlHk9lB3.d.mts → index-vuHRWh8m.d.mts} +23 -19
  38. package/dist/index-vuHRWh8m.d.mts.map +1 -0
  39. package/dist/{migration-CkdSQ8g8.d.mts → migration-BoLlkc9N.d.mts} +2 -2
  40. package/dist/{migration-CkdSQ8g8.d.mts.map → migration-BoLlkc9N.d.mts.map} +1 -1
  41. package/dist/orm-client.d.mts +60 -25
  42. package/dist/orm-client.d.mts.map +1 -1
  43. package/dist/orm-client.mjs +1148 -730
  44. package/dist/orm-client.mjs.map +1 -1
  45. package/dist/query-lane-context-Bku0eZ9n.d.mts +1 -0
  46. package/dist/{query-lane-context-DRO74vm5-BbGhhycI.d.mts → query-lane-context-sTTORN1t-BShwHBX6.d.mts} +4 -4
  47. package/dist/{query-lane-context-DRO74vm5-BbGhhycI.d.mts.map → query-lane-context-sTTORN1t-BShwHBX6.d.mts.map} +1 -1
  48. package/dist/relational-core.d.mts +8 -8
  49. package/dist/relational-core__aggregate-descriptor-registry.d.mts +1 -1
  50. package/dist/relational-core__ast.d.mts +3 -3
  51. package/dist/relational-core__codec-descriptor-registry.d.mts +1 -1
  52. package/dist/relational-core__collection-methods.d.mts +2 -2
  53. package/dist/relational-core__expression.d.mts +3 -3
  54. package/dist/relational-core__functions.d.mts +2 -2
  55. package/dist/relational-core__index-reference.d.mts +2 -2
  56. package/dist/relational-core__query-lane-context.d.mts +2 -2
  57. package/dist/relational-core__types.d.mts +2 -2
  58. package/dist/runtime.d.mts +5 -5
  59. package/dist/runtime.mjs +1 -1
  60. package/dist/runtime__internal__prepared-query.d.mts +2 -2
  61. package/dist/runtime__internal__prepared-query.mjs +2 -2
  62. package/dist/{transaction-state-DR3nKTmH-DO1YOoZJ.d.mts → transaction-state-CEe4TlC1-BGIdTh1r.d.mts} +10 -9
  63. package/dist/{transaction-state-DR3nKTmH-DO1YOoZJ.d.mts.map → transaction-state-CEe4TlC1-BGIdTh1r.d.mts.map} +1 -1
  64. package/dist/{types-COXfSNOP-CA6F1reR.d.mts → types-COXfSNOP-DIsV7kxg.d.mts} +2 -2
  65. package/dist/{types-COXfSNOP-CA6F1reR.d.mts.map → types-COXfSNOP-DIsV7kxg.d.mts.map} +1 -1
  66. package/dist/{types-DpgxiOSn-DrRvhBfy.d.mts → types-QoMfRyfh-Cg6Cam8W.d.mts} +4 -4
  67. package/dist/{types-DpgxiOSn-DrRvhBfy.d.mts.map → types-QoMfRyfh-Cg6Cam8W.d.mts.map} +1 -1
  68. package/dist/types-f_lF2HSL.d.mts +1 -0
  69. package/package.json +18 -18
  70. package/dist/collection-methods-B6AtdlXI.d.mts +0 -1
  71. package/dist/driver-types-Bobm0hWv-B9rTP8XQ.d.mts.map +0 -1
  72. package/dist/exports-WNaGWaJR-C6wltYlN.mjs.map +0 -1
  73. package/dist/expression-CMV-f0HM.d.mts +0 -2
  74. package/dist/expression-DSAx-7Ri-C4W_nQ6T.d.mts.map +0 -1
  75. package/dist/functions-CLrZo2Gj.d.mts +0 -1
  76. package/dist/index-reference-C4a-sIjK.d.mts +0 -1
  77. package/dist/index-rlHk9lB3.d.mts.map +0 -1
  78. package/dist/query-lane-context-CNY3sTaF.d.mts +0 -1
  79. package/dist/types-CSORxTRT.d.mts +0 -1
@@ -18,7 +18,7 @@ import { checkContractComponentRequirements, mergeCapabilityMatrices } from "@pr
18
18
  import { AsyncIterableResult, RuntimeCore, applyMutationDefaults, assertMutationDefaultGeneratorsAvailable, checkAborted, checkMiddlewareCompatibility, collectMutationDefaultGenerators, createContextBeneath, executeStatement, raceAgainstAbort, runtimeError as runtimeError$1, startClientActivity, startTransactionActivity, streamStatement } from "@prisma/orm-framework/components/runtime";
19
19
  import { createExecutionStack } from "@prisma/orm-framework/components/execution";
20
20
  import { hashContent } from "@prisma/orm-framework/utils/hash-content";
21
- //#region ../../../2-sql-family/5-runtime/dist/exports-WNaGWaJR.mjs
21
+ //#region ../../../2-sql-family/5-runtime/dist/exports-cGSgYmrd.mjs
22
22
  /** The symbol-keyed member through which a runtime, connection, transaction, `withTransaction` context or activity handle starts activities; user-facing types do not show it. */
23
23
  const activitySource = Symbol("activitySource");
24
24
  function hasActivitySourceMember(target) {
@@ -1270,6 +1270,11 @@ function validateSqlPlan(plan, contract) {
1270
1270
  contractStorageHash: contract.storage.storageHash
1271
1271
  });
1272
1272
  }
1273
+ function validateTransactionTimeout(timeout) {
1274
+ if (timeout === void 0 || timeout === null) return void 0;
1275
+ if (!Number.isInteger(timeout) || timeout < 1 || timeout > 2147483647) throw runtimeError$1("RUNTIME.INVALID_TRANSACTION_TIMEOUT", "Transaction timeout must be an integer between 1 and 2147483647 milliseconds", { timeout });
1276
+ return timeout;
1277
+ }
1273
1278
  function isExecutionPlan(plan) {
1274
1279
  return "sql" in plan;
1275
1280
  }
@@ -1314,6 +1319,7 @@ var SqlRuntimeBase = class extends RuntimeCore {
1314
1319
  #inFlight = new InFlightOperations();
1315
1320
  #openTransactionWork = new InFlightOperations();
1316
1321
  #transactionWorkOn = /* @__PURE__ */ new WeakMap();
1322
+ #transactionChecks = /* @__PURE__ */ new WeakMap();
1317
1323
  #openActivityHandles = 0;
1318
1324
  #refusing = false;
1319
1325
  #heldQueryables = /* @__PURE__ */ new WeakSet();
@@ -1441,7 +1447,7 @@ var SqlRuntimeBase = class extends RuntimeCore {
1441
1447
  [activitySource] = {
1442
1448
  startActivity: (activity) => {
1443
1449
  this.#runtimeRoute ??= this.queryableRoute(this.driver, "runtime", () => void 0, {
1444
- transaction: (parent) => this.beginOwnedTransactionBeneath(parent),
1450
+ transaction: (parent, options) => this.beginOwnedTransactionBeneath(parent, options),
1445
1451
  runtimeWork: true
1446
1452
  });
1447
1453
  return this.startActivityOnRoute(this.#runtimeRoute, activity, void 0);
@@ -1525,14 +1531,14 @@ var SqlRuntimeBase = class extends RuntimeCore {
1525
1531
  connectionRoute(connection, owner) {
1526
1532
  const openTransaction = this.#openTransactions.get(connection);
1527
1533
  return this.queryableRoute(connection, "connection", () => openTransaction, {
1528
- transaction: openTransaction === void 0 ? (parent) => this.beginTransactionBeneathOn(connection, owner, parent) : void 0,
1534
+ transaction: openTransaction === void 0 ? (parent, options) => this.beginTransactionBeneathOn(connection, owner, parent, options) : void 0,
1529
1535
  runtimeWork: false
1530
1536
  });
1531
1537
  }
1532
- beginTransactionBeneathOn(connection, owner, parent) {
1538
+ beginTransactionBeneathOn(connection, owner, parent, options) {
1533
1539
  const openTransaction = this.#openTransactions.get(connection);
1534
1540
  if (openTransaction !== void 0) return Promise.reject(transactionAlreadyOpenError(parent, openTransaction));
1535
- return this.beginTransactionOn(connection, owner, parent);
1541
+ return this.beginTransactionOn(connection, owner, parent, options);
1536
1542
  }
1537
1543
  /** The `activitySource` member of a held connection that `owner()` wraps. */
1538
1544
  connectionActivitySource(connection, owner) {
@@ -1595,14 +1601,16 @@ var SqlRuntimeBase = class extends RuntimeCore {
1595
1601
  };
1596
1602
  const beginTransaction = route.transaction;
1597
1603
  if (beginTransaction === void 0) return handle;
1598
- return Object.assign(handle, { transaction: async () => {
1604
+ return Object.assign(handle, { transaction: async (options) => {
1599
1605
  run.assertAcceptsChildren();
1600
- return beginTransaction(run);
1606
+ validateTransactionTimeout(options?.timeout);
1607
+ return beginTransaction(run, options);
1601
1608
  } });
1602
1609
  }
1603
- async beginOwnedTransactionBeneath(parent) {
1610
+ async beginOwnedTransactionBeneath(parent, options) {
1611
+ validateTransactionTimeout(options?.timeout);
1604
1612
  const { driverConnection, connection } = await this.openConnection({ activityParent: parent });
1605
- return this.ownTransaction(connection, () => this.beginTransactionOn(driverConnection, connection, parent));
1613
+ return this.ownTransaction(connection, () => this.beginTransactionOn(driverConnection, connection, parent, options));
1606
1614
  }
1607
1615
  /** Begins a transaction with `begin` on a connection the transaction owns; see `beginOwnedTransaction`. */
1608
1616
  ownTransaction(connection, begin) {
@@ -1623,13 +1631,14 @@ var SqlRuntimeBase = class extends RuntimeCore {
1623
1631
  try {
1624
1632
  await this.#inFlight.track(teardown);
1625
1633
  } finally {
1626
- this.#transactionWorkOn.get(held)?.();
1634
+ const ending = this.#transactionWorkOn.get(held)?.();
1635
+ if (ending !== void 0) await ending;
1627
1636
  }
1628
1637
  };
1629
1638
  const held = {
1630
1639
  query: (request) => this.trackRows(connection.query(request)),
1631
1640
  execute: (request) => this.#inFlight.track(() => connection.execute(request)),
1632
- beginTransaction: () => connection.beginTransaction(),
1641
+ beginTransaction: (options) => connection.beginTransaction(options),
1633
1642
  ...ifDefined("explain", connection.explain?.bind(connection)),
1634
1643
  release: () => dispose(() => connection.release()),
1635
1644
  destroy: (reason) => dispose(() => connection.destroy(reason))
@@ -1703,7 +1712,10 @@ var SqlRuntimeBase = class extends RuntimeCore {
1703
1712
  const startedAt = Date.now();
1704
1713
  let telemetryOutcome = null;
1705
1714
  try {
1706
- const iterator = run.runQuery(exec, driverCall)[Symbol.asyncIterator]();
1715
+ const iterator = run.runQuery(exec, () => {
1716
+ this.#transactionChecks.get(queryable)?.();
1717
+ return driverCall();
1718
+ })[Symbol.asyncIterator]();
1707
1719
  let answered = false;
1708
1720
  try {
1709
1721
  while (true) {
@@ -1819,7 +1831,10 @@ var SqlRuntimeBase = class extends RuntimeCore {
1819
1831
  const startedAt = Date.now();
1820
1832
  let telemetryOutcome = "success";
1821
1833
  try {
1822
- return await run.runExecute(exec, driverCall);
1834
+ return await run.runExecute(exec, () => {
1835
+ this.#transactionChecks.get(queryable)?.();
1836
+ return driverCall();
1837
+ });
1823
1838
  } catch (error) {
1824
1839
  telemetryOutcome = "runtime-error";
1825
1840
  throw error;
@@ -1956,8 +1971,8 @@ var SqlRuntimeBase = class extends RuntimeCore {
1956
1971
  const self = this;
1957
1972
  const wrappedConnection = {
1958
1973
  [transactionStart]: createTransactionStart(),
1959
- transaction() {
1960
- return self.beginTransactionOn(driverConn, wrappedConnection, void 0);
1974
+ transaction(options) {
1975
+ return self.beginTransactionOn(driverConn, wrappedConnection, void 0, options);
1961
1976
  },
1962
1977
  [activitySource]: self.connectionActivitySource(driverConn, () => wrappedConnection),
1963
1978
  release: () => driverConn.release(),
@@ -1995,7 +2010,10 @@ var SqlRuntimeBase = class extends RuntimeCore {
1995
2010
  /**
1996
2011
  * Begins a transaction on `connection`, which `owner` wraps, as a transaction activity. When the transaction's `activityStarted` hooks refuse the start, no `BEGIN` is sent, `owner` is recorded as clean, and `withTransaction` releases it; after any other start failure it destroys it. The transaction's `activityStarted` hooks run before `BEGIN`. Every statement sent on the transaction, or on `connection`, from the end of `BEGIN` until `commit()` or `rollback()` is called is the transaction's child, and is finalized when the transaction ends, with its outcome. `commit()` and `rollback()` resolve after every finalization hook has run. A subclass that holds its own connection begins its transactions here.
1997
2012
  */
1998
- async beginTransactionOn(connection, owner, parent) {
2013
+ async beginTransactionOn(connection, owner, parent, options) {
2014
+ owner[transactionStart].refusedBeforeBegin = true;
2015
+ const timeout = validateTransactionTimeout(options?.timeout);
2016
+ const { timeout: _timeout, ...driverOptions } = options ?? {};
1999
2017
  owner[transactionStart].refusedBeforeBegin = false;
2000
2018
  const endTransactionWork = this.#openTransactionWork.begin();
2001
2019
  this.#transactionWorkOn.set(connection, endTransactionWork);
@@ -2017,7 +2035,7 @@ var SqlRuntimeBase = class extends RuntimeCore {
2017
2035
  }
2018
2036
  let driverTx;
2019
2037
  try {
2020
- driverTx = await connection.beginTransaction();
2038
+ driverTx = await connection.beginTransaction(options === void 0 ? void 0 : driverOptions);
2021
2039
  } catch (error) {
2022
2040
  endTransactionWork();
2023
2041
  await activity.end({
@@ -2028,14 +2046,14 @@ var SqlRuntimeBase = class extends RuntimeCore {
2028
2046
  throw error;
2029
2047
  }
2030
2048
  if (this.#heldQueryables.has(connection)) this.#heldQueryables.add(driverTx);
2031
- return this.wrapTransaction(driverTx, connection, activity, endTransactionWork);
2049
+ return this.wrapTransaction(driverTx, connection, activity, endTransactionWork, timeout);
2032
2050
  }
2033
- wrapTransaction(driverTx, connection, activity, endTransactionWork) {
2051
+ wrapTransaction(driverTx, connection, activity, endTransactionWork, timeout) {
2034
2052
  this.#openTransactions.set(driverTx, activity);
2035
2053
  this.#openTransactions.set(connection, activity);
2036
2054
  const stopAcceptingChildren = () => {
2037
2055
  activity.stopAcceptingChildren();
2038
- for (const queryable of [driverTx, connection]) if (this.#openTransactions.get(queryable) === activity) this.#openTransactions.delete(queryable);
2056
+ for (const queryable of timeout === void 0 ? [driverTx, connection] : [connection]) if (this.#openTransactions.get(queryable) === activity) this.#openTransactions.delete(queryable);
2039
2057
  };
2040
2058
  let commitAttempted = false;
2041
2059
  const settlement = {
@@ -2051,10 +2069,56 @@ var SqlRuntimeBase = class extends RuntimeCore {
2051
2069
  }
2052
2070
  };
2053
2071
  let commitEnding;
2072
+ const controller = new AbortController();
2073
+ const deadline = performance.now() + (timeout ?? Number.POSITIVE_INFINITY);
2074
+ let closed = false;
2075
+ let timer;
2076
+ const stopDeadline = () => {
2077
+ clearTimeout(timer);
2078
+ timer = void 0;
2079
+ closed = true;
2080
+ };
2081
+ const expire = () => {
2082
+ if (closed) return;
2083
+ stopDeadline();
2084
+ activity.stopAcceptingChildren();
2085
+ controller.abort(runtimeError$1("RUNTIME.TRANSACTION_TIMEOUT", "Transaction callback exceeded its timeout", { timeout }));
2086
+ };
2087
+ const check = () => {
2088
+ if (timeout === void 0) return;
2089
+ if (!closed && performance.now() >= deadline) expire();
2090
+ controller.signal.throwIfAborted();
2091
+ if (closed) throw transactionClosedError();
2092
+ };
2093
+ if (timeout !== void 0) {
2094
+ timer = setTimeout(expire, timeout);
2095
+ this.#transactionChecks.set(driverTx, check);
2096
+ this.#transactionWorkOn.set(connection, async () => {
2097
+ stopDeadline();
2098
+ stopAcceptingChildren();
2099
+ try {
2100
+ if (!settlement.committed && !settlement.rolledBack) {
2101
+ settlement.rolledBack = true;
2102
+ await activity.end({
2103
+ by: "rollback",
2104
+ outcome: "failed",
2105
+ commitAttempted
2106
+ });
2107
+ }
2108
+ } catch (error) {
2109
+ settlement.logDroppedError(error);
2110
+ } finally {
2111
+ endTransactionWork();
2112
+ }
2113
+ });
2114
+ }
2054
2115
  const self = this;
2055
2116
  return {
2056
2117
  [transactionSettlement]: settlement,
2118
+ signal: controller.signal,
2057
2119
  async commit() {
2120
+ check();
2121
+ stopDeadline();
2058
2122
  commitAttempted = true;
2059
2123
  stopAcceptingChildren();
2060
2124
  try {
@@ -2079,6 +2143,7 @@ var SqlRuntimeBase = class extends RuntimeCore {
2079
2143
  }
2080
2144
  },
2081
2145
  async rollback() {
2146
+ stopDeadline();
2082
2147
  stopAcceptingChildren();
2083
2148
  if (settlement.committed) {
2084
2149
  await commitEnding?.catch(() => void 0);
@@ -2294,17 +2359,30 @@ function transactionClosedError() {
2294
2359
  function withTransactionMembers(txCtx, members) {
2295
2360
  return Object.assign(castAs(Object.create(txCtx)), members);
2296
2361
  }
2297
- async function withTransaction(runtime, fn) {
2362
+ async function withTransaction(runtime, fn, options) {
2363
+ validateTransactionTimeout(options?.timeout);
2364
+ let invalidated = false;
2298
2365
  const connection = await runtime.connection();
2299
2366
  let transaction;
2300
2367
  try {
2301
- transaction = await connection.transaction();
2368
+ transaction = await connection.transaction(options);
2302
2369
  } catch (error) {
2303
2370
  if (wasRefusedBeforeBegin(connection)) await connection.release().catch(() => void 0);
2304
2371
  else await connection.destroy(error).catch(() => void 0);
2305
2372
  throw error;
2306
2373
  }
2307
- let invalidated = false;
2374
+ const signal = transaction.signal;
2375
+ let rejectAbort = (_reason) => {};
2376
+ const aborted = new Promise((_, reject) => {
2377
+ rejectAbort = reject;
2378
+ });
2379
+ aborted.catch(() => void 0);
2380
+ const onAbort = () => {
2381
+ invalidated = true;
2382
+ rejectAbort(signal.reason);
2383
+ };
2384
+ signal.addEventListener("abort", onAbort, { once: true });
2385
+ if (signal.aborted) onAbort();
2308
2386
  async function* guardedStream(open) {
2309
2387
  if (invalidated) throw transactionClosedError();
2310
2388
  for await (const row of open()) {
@@ -2367,45 +2445,50 @@ async function withTransaction(runtime, fn) {
2367
2445
  connectionDisposed = true;
2368
2446
  await connection.destroy(reason).catch(() => void 0);
2369
2447
  };
2448
+ let commitRequested = false;
2370
2449
  try {
2371
- let result;
2372
- try {
2373
- result = await fn(txContext);
2374
- } catch (error) {
2450
+ signal.throwIfAborted();
2451
+ const result = await Promise.race([Promise.resolve(fn(txContext)), aborted]);
2452
+ invalidated = true;
2453
+ commitRequested = true;
2454
+ await transaction.commit();
2455
+ return result;
2456
+ } catch (error) {
2457
+ if (signal.aborted) {
2458
+ await destroyConnection(signal.reason);
2459
+ throw signal.reason;
2460
+ }
2461
+ if (!commitRequested) {
2462
+ const selected = error;
2375
2463
  try {
2376
2464
  await transaction.rollback();
2377
2465
  } catch (rollbackError) {
2378
2466
  const settlement = settlementOf(transaction);
2379
2467
  if (settlement?.rolledBack === true) {
2380
2468
  settlement.logDroppedError(rollbackError);
2381
- throw error;
2469
+ throw selected;
2382
2470
  }
2383
2471
  await destroyConnection(rollbackError);
2384
2472
  const wrapped = runtimeError$1("RUNTIME.TRANSACTION_ROLLBACK_FAILED", "Transaction rollback failed after callback error", { rollbackError });
2385
- wrapped.cause = error;
2473
+ wrapped.cause = selected;
2386
2474
  throw wrapped;
2387
2475
  }
2388
- throw error;
2389
- } finally {
2390
- invalidated = true;
2476
+ throw selected;
2391
2477
  }
2478
+ if (settlementOf(transaction)?.committed === true) throw error;
2392
2479
  try {
2393
- await transaction.commit();
2394
- } catch (commitError) {
2395
- if (settlementOf(transaction)?.committed === true) throw commitError;
2396
- try {
2397
- await transaction.rollback();
2398
- } catch (rollbackError) {
2399
- const settlement = settlementOf(transaction);
2400
- if (settlement?.rolledBack === true) settlement.logDroppedError(rollbackError);
2401
- else await destroyConnection(commitError);
2402
- }
2403
- const wrapped = runtimeError$1("RUNTIME.TRANSACTION_COMMIT_FAILED", "Transaction commit failed", { commitError });
2404
- wrapped.cause = commitError;
2405
- throw wrapped;
2480
+ await transaction.rollback();
2481
+ } catch (rollbackError) {
2482
+ const settlement = settlementOf(transaction);
2483
+ if (settlement?.rolledBack === true) settlement.logDroppedError(rollbackError);
2484
+ else await destroyConnection(error);
2406
2485
  }
2407
- return result;
2486
+ const wrapped = runtimeError$1("RUNTIME.TRANSACTION_COMMIT_FAILED", "Transaction commit failed", { commitError: error });
2487
+ wrapped.cause = error;
2488
+ throw wrapped;
2408
2489
  } finally {
2490
+ invalidated = true;
2491
+ signal.removeEventListener("abort", onAbort);
2409
2492
  if (!connectionDisposed) await connection.release();
2410
2493
  }
2411
2494
  }
@@ -2424,4 +2507,4 @@ function createToSql(stack, contract) {
2424
2507
  //#endregion
2425
2508
  export { validateContractCodecMappings as C, validateCodecRegistryCompleteness as S, withTransactionMembers as T, lints as _, budgets as a, startActivityOn as b, createSqlExecutionStack as c, delegatingRuntime as d, deriveParamMetadata as f, lazyActivitySource as g, findActivitySource as h, activitySource as i, createToSql as l, extractCodecIds as m, PreparedStatementImpl as n, createAstCodecRegistry as o, encodeParamsWithMetadata as p, SqlRuntimeBase as r, createExecutionContext as s, PreparedExecutionImpl as t, delegatingActivitySource as u, lowerSqlPlan as v, withTransaction as w, toRuntimeOptions as x, planContentHashOn as y };
2426
2509
 
2427
- //# sourceMappingURL=exports-WNaGWaJR-C6wltYlN.mjs.map
2510
+ //# sourceMappingURL=exports-cGSgYmrd-BADpxA8G.mjs.map