@prisma/client-engine-runtime 7.1.0-dev.3 → 7.1.0-dev.31

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
@@ -1441,7 +1441,7 @@ var QueryInterpreter = class _QueryInterpreter {
1441
1441
  #serializer;
1442
1442
  #rawSerializer;
1443
1443
  #provider;
1444
- #connectioInfo;
1444
+ #connectionInfo;
1445
1445
  constructor({
1446
1446
  transactionManager,
1447
1447
  placeholderValues,
@@ -1459,7 +1459,7 @@ var QueryInterpreter = class _QueryInterpreter {
1459
1459
  this.#serializer = serializer;
1460
1460
  this.#rawSerializer = rawSerializer ?? serializer;
1461
1461
  this.#provider = provider;
1462
- this.#connectioInfo = connectionInfo;
1462
+ this.#connectionInfo = connectionInfo;
1463
1463
  }
1464
1464
  static forSql(options) {
1465
1465
  return new _QueryInterpreter({
@@ -1673,8 +1673,8 @@ var QueryInterpreter = class _QueryInterpreter {
1673
1673
  }
1674
1674
  }
1675
1675
  #maxChunkSize() {
1676
- if (this.#connectioInfo?.maxBindValues !== void 0) {
1677
- return this.#connectioInfo.maxBindValues;
1676
+ if (this.#connectionInfo?.maxBindValues !== void 0) {
1677
+ return this.#connectionInfo.maxBindValues;
1678
1678
  }
1679
1679
  return this.#providerMaxChunkSize();
1680
1680
  }
@@ -1851,6 +1851,13 @@ async function randomUUID() {
1851
1851
  return crypto.randomUUID();
1852
1852
  }
1853
1853
 
1854
+ // src/web-platform.ts
1855
+ async function once(target, event) {
1856
+ return new Promise((resolve) => {
1857
+ target.addEventListener(event, resolve, { once: true });
1858
+ });
1859
+ }
1860
+
1854
1861
  // src/transaction-manager/transaction-manager-error.ts
1855
1862
  var TransactionManagerError = class extends UserFacingError {
1856
1863
  name = "TransactionManagerError";
@@ -1966,15 +1973,17 @@ var TransactionManager = class {
1966
1973
  startedAt: Date.now(),
1967
1974
  transaction: void 0
1968
1975
  };
1969
- this.transactions.set(transaction.id, transaction);
1970
- let hasTimedOut = false;
1971
- const startTimer = createTimeoutIfDefined(() => hasTimedOut = true, options.maxWait);
1976
+ const abortController = new AbortController();
1977
+ const startTimer = createTimeoutIfDefined(() => abortController.abort(), options.maxWait);
1972
1978
  startTimer?.unref?.();
1973
- transaction.transaction = await this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
1974
- clearTimeout(startTimer);
1979
+ transaction.transaction = await Promise.race([
1980
+ this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing).finally(() => clearTimeout(startTimer)),
1981
+ once(abortController.signal, "abort").then(() => void 0)
1982
+ ]);
1983
+ this.transactions.set(transaction.id, transaction);
1975
1984
  switch (transaction.status) {
1976
1985
  case "waiting":
1977
- if (hasTimedOut) {
1986
+ if (abortController.signal.aborted) {
1978
1987
  await this.#closeTransaction(transaction, "timed_out");
1979
1988
  throw new TransactionStartTimeoutError();
1980
1989
  }
package/dist/index.mjs CHANGED
@@ -1391,7 +1391,7 @@ var QueryInterpreter = class _QueryInterpreter {
1391
1391
  #serializer;
1392
1392
  #rawSerializer;
1393
1393
  #provider;
1394
- #connectioInfo;
1394
+ #connectionInfo;
1395
1395
  constructor({
1396
1396
  transactionManager,
1397
1397
  placeholderValues,
@@ -1409,7 +1409,7 @@ var QueryInterpreter = class _QueryInterpreter {
1409
1409
  this.#serializer = serializer;
1410
1410
  this.#rawSerializer = rawSerializer ?? serializer;
1411
1411
  this.#provider = provider;
1412
- this.#connectioInfo = connectionInfo;
1412
+ this.#connectionInfo = connectionInfo;
1413
1413
  }
1414
1414
  static forSql(options) {
1415
1415
  return new _QueryInterpreter({
@@ -1623,8 +1623,8 @@ var QueryInterpreter = class _QueryInterpreter {
1623
1623
  }
1624
1624
  }
1625
1625
  #maxChunkSize() {
1626
- if (this.#connectioInfo?.maxBindValues !== void 0) {
1627
- return this.#connectioInfo.maxBindValues;
1626
+ if (this.#connectionInfo?.maxBindValues !== void 0) {
1627
+ return this.#connectionInfo.maxBindValues;
1628
1628
  }
1629
1629
  return this.#providerMaxChunkSize();
1630
1630
  }
@@ -1801,6 +1801,13 @@ async function randomUUID() {
1801
1801
  return crypto.randomUUID();
1802
1802
  }
1803
1803
 
1804
+ // src/web-platform.ts
1805
+ async function once(target, event) {
1806
+ return new Promise((resolve) => {
1807
+ target.addEventListener(event, resolve, { once: true });
1808
+ });
1809
+ }
1810
+
1804
1811
  // src/transaction-manager/transaction-manager-error.ts
1805
1812
  var TransactionManagerError = class extends UserFacingError {
1806
1813
  name = "TransactionManagerError";
@@ -1916,15 +1923,17 @@ var TransactionManager = class {
1916
1923
  startedAt: Date.now(),
1917
1924
  transaction: void 0
1918
1925
  };
1919
- this.transactions.set(transaction.id, transaction);
1920
- let hasTimedOut = false;
1921
- const startTimer = createTimeoutIfDefined(() => hasTimedOut = true, options.maxWait);
1926
+ const abortController = new AbortController();
1927
+ const startTimer = createTimeoutIfDefined(() => abortController.abort(), options.maxWait);
1922
1928
  startTimer?.unref?.();
1923
- transaction.transaction = await this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing);
1924
- clearTimeout(startTimer);
1929
+ transaction.transaction = await Promise.race([
1930
+ this.driverAdapter.startTransaction(options.isolationLevel).catch(rethrowAsUserFacing).finally(() => clearTimeout(startTimer)),
1931
+ once(abortController.signal, "abort").then(() => void 0)
1932
+ ]);
1933
+ this.transactions.set(transaction.id, transaction);
1925
1934
  switch (transaction.status) {
1926
1935
  case "waiting":
1927
- if (hasTimedOut) {
1936
+ if (abortController.signal.aborted) {
1928
1937
  await this.#closeTransaction(transaction, "timed_out");
1929
1938
  throw new TransactionStartTimeoutError();
1930
1939
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Equivalent to `once` from `node:events` for DOM {@link EventTarget}.
3
+ *
4
+ * It is useful, e.g., to wait for an `abort` event on {@link AbortSignal}.
5
+ * While in Node.js `AbortSignal` does implement `EventEmitter` interface
6
+ * and is compatible with the `once` utility in `node:events`, it is not
7
+ * necessarily the case in other JS runtimes.
8
+ */
9
+ export declare function once(target: EventTarget, event: string): Promise<Event>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/client-engine-runtime",
3
- "version": "7.1.0-dev.3",
3
+ "version": "7.1.0-dev.31",
4
4
  "description": "This package is intended for Prisma's internal use",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -30,9 +30,9 @@
30
30
  "nanoid": "5.1.5",
31
31
  "ulid": "3.0.0",
32
32
  "uuid": "11.1.0",
33
- "@prisma/client-runtime-utils": "7.1.0-dev.3",
34
- "@prisma/debug": "7.1.0-dev.3",
35
- "@prisma/driver-adapter-utils": "7.1.0-dev.3"
33
+ "@prisma/client-runtime-utils": "7.1.0-dev.31",
34
+ "@prisma/debug": "7.1.0-dev.31",
35
+ "@prisma/driver-adapter-utils": "7.1.0-dev.31"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/jest": "29.5.14",