@stablyai/playwright-test 2.0.15 → 2.0.16

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.
@@ -6386,204 +6386,331 @@ function requireWebsocketServer () {
6386
6386
 
6387
6387
  requireWebsocketServer();
6388
6388
 
6389
- const objectToString = Object.prototype.toString;
6390
- const isError = (value) => objectToString.call(value) === "[object Error]";
6391
- const errorMessages = /* @__PURE__ */ new Set([
6392
- "network error",
6393
- // Chrome
6394
- "Failed to fetch",
6395
- // Chrome
6396
- "NetworkError when attempting to fetch resource.",
6397
- // Firefox
6398
- "The Internet connection appears to be offline.",
6399
- // Safari 16
6400
- "Network request failed",
6401
- // `cross-fetch`
6402
- "fetch failed",
6403
- // Undici (Node.js)
6404
- "terminated",
6405
- // Undici (Node.js)
6406
- " A network error occurred.",
6407
- // Bun (WebKit)
6408
- "Network connection lost"
6409
- // Cloudflare Workers (fetch)
6410
- ]);
6411
- function isNetworkError(error) {
6412
- const isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
6413
- if (!isValid) {
6414
- return false;
6415
- }
6416
- const { message, stack } = error;
6417
- if (message === "Load failed") {
6418
- return stack === void 0 || "__sentry_captured__" in error;
6419
- }
6420
- if (message.startsWith("error sending request for url")) {
6421
- return true;
6422
- }
6423
- return errorMessages.has(message);
6424
- }
6389
+ var pRetry = {exports: {}};
6425
6390
 
6426
- function validateRetries(retries) {
6427
- if (typeof retries === "number") {
6428
- if (retries < 0) {
6429
- throw new TypeError("Expected `retries` to be a non-negative number.");
6430
- }
6431
- if (Number.isNaN(retries)) {
6432
- throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.");
6433
- }
6434
- } else if (retries !== void 0) {
6435
- throw new TypeError("Expected `retries` to be a number or Infinity.");
6436
- }
6391
+ var retry$1 = {};
6392
+
6393
+ var retry_operation;
6394
+ var hasRequiredRetry_operation;
6395
+
6396
+ function requireRetry_operation () {
6397
+ if (hasRequiredRetry_operation) return retry_operation;
6398
+ hasRequiredRetry_operation = 1;
6399
+ function RetryOperation(timeouts, options) {
6400
+ if (typeof options === "boolean") {
6401
+ options = { forever: options };
6402
+ }
6403
+ this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
6404
+ this._timeouts = timeouts;
6405
+ this._options = options || {};
6406
+ this._maxRetryTime = options && options.maxRetryTime || Infinity;
6407
+ this._fn = null;
6408
+ this._errors = [];
6409
+ this._attempts = 1;
6410
+ this._operationTimeout = null;
6411
+ this._operationTimeoutCb = null;
6412
+ this._timeout = null;
6413
+ this._operationStart = null;
6414
+ this._timer = null;
6415
+ if (this._options.forever) {
6416
+ this._cachedTimeouts = this._timeouts.slice(0);
6417
+ }
6418
+ }
6419
+ retry_operation = RetryOperation;
6420
+ RetryOperation.prototype.reset = function() {
6421
+ this._attempts = 1;
6422
+ this._timeouts = this._originalTimeouts.slice(0);
6423
+ };
6424
+ RetryOperation.prototype.stop = function() {
6425
+ if (this._timeout) {
6426
+ clearTimeout(this._timeout);
6427
+ }
6428
+ if (this._timer) {
6429
+ clearTimeout(this._timer);
6430
+ }
6431
+ this._timeouts = [];
6432
+ this._cachedTimeouts = null;
6433
+ };
6434
+ RetryOperation.prototype.retry = function(err) {
6435
+ if (this._timeout) {
6436
+ clearTimeout(this._timeout);
6437
+ }
6438
+ if (!err) {
6439
+ return false;
6440
+ }
6441
+ var currentTime = (/* @__PURE__ */ new Date()).getTime();
6442
+ if (err && currentTime - this._operationStart >= this._maxRetryTime) {
6443
+ this._errors.push(err);
6444
+ this._errors.unshift(new Error("RetryOperation timeout occurred"));
6445
+ return false;
6446
+ }
6447
+ this._errors.push(err);
6448
+ var timeout = this._timeouts.shift();
6449
+ if (timeout === void 0) {
6450
+ if (this._cachedTimeouts) {
6451
+ this._errors.splice(0, this._errors.length - 1);
6452
+ timeout = this._cachedTimeouts.slice(-1);
6453
+ } else {
6454
+ return false;
6455
+ }
6456
+ }
6457
+ var self = this;
6458
+ this._timer = setTimeout(function() {
6459
+ self._attempts++;
6460
+ if (self._operationTimeoutCb) {
6461
+ self._timeout = setTimeout(function() {
6462
+ self._operationTimeoutCb(self._attempts);
6463
+ }, self._operationTimeout);
6464
+ if (self._options.unref) {
6465
+ self._timeout.unref();
6466
+ }
6467
+ }
6468
+ self._fn(self._attempts);
6469
+ }, timeout);
6470
+ if (this._options.unref) {
6471
+ this._timer.unref();
6472
+ }
6473
+ return true;
6474
+ };
6475
+ RetryOperation.prototype.attempt = function(fn, timeoutOps) {
6476
+ this._fn = fn;
6477
+ if (timeoutOps) {
6478
+ if (timeoutOps.timeout) {
6479
+ this._operationTimeout = timeoutOps.timeout;
6480
+ }
6481
+ if (timeoutOps.cb) {
6482
+ this._operationTimeoutCb = timeoutOps.cb;
6483
+ }
6484
+ }
6485
+ var self = this;
6486
+ if (this._operationTimeoutCb) {
6487
+ this._timeout = setTimeout(function() {
6488
+ self._operationTimeoutCb();
6489
+ }, self._operationTimeout);
6490
+ }
6491
+ this._operationStart = (/* @__PURE__ */ new Date()).getTime();
6492
+ this._fn(this._attempts);
6493
+ };
6494
+ RetryOperation.prototype.try = function(fn) {
6495
+ console.log("Using RetryOperation.try() is deprecated");
6496
+ this.attempt(fn);
6497
+ };
6498
+ RetryOperation.prototype.start = function(fn) {
6499
+ console.log("Using RetryOperation.start() is deprecated");
6500
+ this.attempt(fn);
6501
+ };
6502
+ RetryOperation.prototype.start = RetryOperation.prototype.try;
6503
+ RetryOperation.prototype.errors = function() {
6504
+ return this._errors;
6505
+ };
6506
+ RetryOperation.prototype.attempts = function() {
6507
+ return this._attempts;
6508
+ };
6509
+ RetryOperation.prototype.mainError = function() {
6510
+ if (this._errors.length === 0) {
6511
+ return null;
6512
+ }
6513
+ var counts = {};
6514
+ var mainError = null;
6515
+ var mainErrorCount = 0;
6516
+ for (var i = 0; i < this._errors.length; i++) {
6517
+ var error = this._errors[i];
6518
+ var message = error.message;
6519
+ var count = (counts[message] || 0) + 1;
6520
+ counts[message] = count;
6521
+ if (count >= mainErrorCount) {
6522
+ mainError = error;
6523
+ mainErrorCount = count;
6524
+ }
6525
+ }
6526
+ return mainError;
6527
+ };
6528
+ return retry_operation;
6437
6529
  }
6438
- function validateNumberOption(name, value, { min = 0, allowInfinity = false } = {}) {
6439
- if (value === void 0) {
6440
- return;
6441
- }
6442
- if (typeof value !== "number" || Number.isNaN(value)) {
6443
- throw new TypeError(`Expected \`${name}\` to be a number${allowInfinity ? " or Infinity" : ""}.`);
6444
- }
6445
- if (!allowInfinity && !Number.isFinite(value)) {
6446
- throw new TypeError(`Expected \`${name}\` to be a finite number.`);
6447
- }
6448
- if (value < min) {
6449
- throw new TypeError(`Expected \`${name}\` to be \u2265 ${min}.`);
6450
- }
6530
+
6531
+ var hasRequiredRetry$1;
6532
+
6533
+ function requireRetry$1 () {
6534
+ if (hasRequiredRetry$1) return retry$1;
6535
+ hasRequiredRetry$1 = 1;
6536
+ (function (exports$1) {
6537
+ var RetryOperation = requireRetry_operation();
6538
+ exports$1.operation = function(options) {
6539
+ var timeouts = exports$1.timeouts(options);
6540
+ return new RetryOperation(timeouts, {
6541
+ forever: options && (options.forever || options.retries === Infinity),
6542
+ unref: options && options.unref,
6543
+ maxRetryTime: options && options.maxRetryTime
6544
+ });
6545
+ };
6546
+ exports$1.timeouts = function(options) {
6547
+ if (options instanceof Array) {
6548
+ return [].concat(options);
6549
+ }
6550
+ var opts = {
6551
+ retries: 10,
6552
+ factor: 2,
6553
+ minTimeout: 1 * 1e3,
6554
+ maxTimeout: Infinity,
6555
+ randomize: false
6556
+ };
6557
+ for (var key in options) {
6558
+ opts[key] = options[key];
6559
+ }
6560
+ if (opts.minTimeout > opts.maxTimeout) {
6561
+ throw new Error("minTimeout is greater than maxTimeout");
6562
+ }
6563
+ var timeouts = [];
6564
+ for (var i = 0; i < opts.retries; i++) {
6565
+ timeouts.push(this.createTimeout(i, opts));
6566
+ }
6567
+ if (options && options.forever && !timeouts.length) {
6568
+ timeouts.push(this.createTimeout(i, opts));
6569
+ }
6570
+ timeouts.sort(function(a, b) {
6571
+ return a - b;
6572
+ });
6573
+ return timeouts;
6574
+ };
6575
+ exports$1.createTimeout = function(attempt, opts) {
6576
+ var random = opts.randomize ? Math.random() + 1 : 1;
6577
+ var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
6578
+ timeout = Math.min(timeout, opts.maxTimeout);
6579
+ return timeout;
6580
+ };
6581
+ exports$1.wrap = function(obj, options, methods) {
6582
+ if (options instanceof Array) {
6583
+ methods = options;
6584
+ options = null;
6585
+ }
6586
+ if (!methods) {
6587
+ methods = [];
6588
+ for (var key in obj) {
6589
+ if (typeof obj[key] === "function") {
6590
+ methods.push(key);
6591
+ }
6592
+ }
6593
+ }
6594
+ for (var i = 0; i < methods.length; i++) {
6595
+ var method = methods[i];
6596
+ var original = obj[method];
6597
+ obj[method] = function retryWrapper(original2) {
6598
+ var op = exports$1.operation(options);
6599
+ var args = Array.prototype.slice.call(arguments, 1);
6600
+ var callback = args.pop();
6601
+ args.push(function(err) {
6602
+ if (op.retry(err)) {
6603
+ return;
6604
+ }
6605
+ if (err) {
6606
+ arguments[0] = op.mainError();
6607
+ }
6608
+ callback.apply(this, arguments);
6609
+ });
6610
+ op.attempt(function() {
6611
+ original2.apply(obj, args);
6612
+ });
6613
+ }.bind(obj, original);
6614
+ obj[method].options = options;
6615
+ }
6616
+ };
6617
+ } (retry$1));
6618
+ return retry$1;
6451
6619
  }
6452
- class AbortError extends Error {
6453
- constructor(message) {
6454
- super();
6455
- if (message instanceof Error) {
6456
- this.originalError = message;
6457
- ({ message } = message);
6458
- } else {
6459
- this.originalError = new Error(message);
6460
- this.originalError.stack = this.stack;
6461
- }
6462
- this.name = "AbortError";
6463
- this.message = message;
6464
- }
6465
- }
6466
- function calculateDelay(retriesConsumed, options) {
6467
- const attempt = Math.max(1, retriesConsumed + 1);
6468
- const random = options.randomize ? Math.random() + 1 : 1;
6469
- let timeout = Math.round(random * options.minTimeout * options.factor ** (attempt - 1));
6470
- timeout = Math.min(timeout, options.maxTimeout);
6471
- return timeout;
6472
- }
6473
- function calculateRemainingTime(start, max) {
6474
- if (!Number.isFinite(max)) {
6475
- return max;
6476
- }
6477
- return max - (performance.now() - start);
6478
- }
6479
- async function onAttemptFailure({ error, attemptNumber, retriesConsumed, startTime, options }) {
6480
- const normalizedError = error instanceof Error ? error : new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
6481
- if (normalizedError instanceof AbortError) {
6482
- throw normalizedError.originalError;
6483
- }
6484
- const retriesLeft = Number.isFinite(options.retries) ? Math.max(0, options.retries - retriesConsumed) : options.retries;
6485
- const maxRetryTime = options.maxRetryTime ?? Number.POSITIVE_INFINITY;
6486
- const context = Object.freeze({
6487
- error: normalizedError,
6488
- attemptNumber,
6489
- retriesLeft,
6490
- retriesConsumed
6491
- });
6492
- await options.onFailedAttempt(context);
6493
- if (calculateRemainingTime(startTime, maxRetryTime) <= 0) {
6494
- throw normalizedError;
6495
- }
6496
- const consumeRetry = await options.shouldConsumeRetry(context);
6497
- const remainingTime = calculateRemainingTime(startTime, maxRetryTime);
6498
- if (remainingTime <= 0 || retriesLeft <= 0) {
6499
- throw normalizedError;
6500
- }
6501
- if (normalizedError instanceof TypeError && !isNetworkError(normalizedError)) {
6502
- if (consumeRetry) {
6503
- throw normalizedError;
6504
- }
6505
- options.signal?.throwIfAborted();
6506
- return false;
6507
- }
6508
- if (!await options.shouldRetry(context)) {
6509
- throw normalizedError;
6510
- }
6511
- if (!consumeRetry) {
6512
- options.signal?.throwIfAborted();
6513
- return false;
6514
- }
6515
- const delayTime = calculateDelay(retriesConsumed, options);
6516
- const finalDelay = Math.min(delayTime, remainingTime);
6517
- options.signal?.throwIfAborted();
6518
- if (finalDelay > 0) {
6519
- await new Promise((resolve, reject) => {
6520
- const onAbort = () => {
6521
- clearTimeout(timeoutToken);
6522
- options.signal?.removeEventListener("abort", onAbort);
6523
- reject(options.signal.reason);
6524
- };
6525
- const timeoutToken = setTimeout(() => {
6526
- options.signal?.removeEventListener("abort", onAbort);
6527
- resolve();
6528
- }, finalDelay);
6529
- if (options.unref) {
6530
- timeoutToken.unref?.();
6531
- }
6532
- options.signal?.addEventListener("abort", onAbort, { once: true });
6533
- });
6534
- }
6535
- options.signal?.throwIfAborted();
6536
- return true;
6620
+
6621
+ var retry;
6622
+ var hasRequiredRetry;
6623
+
6624
+ function requireRetry () {
6625
+ if (hasRequiredRetry) return retry;
6626
+ hasRequiredRetry = 1;
6627
+ retry = requireRetry$1();
6628
+ return retry;
6537
6629
  }
6538
- async function pRetry(input, options = {}) {
6539
- options = { ...options };
6540
- validateRetries(options.retries);
6541
- if (Object.hasOwn(options, "forever")) {
6542
- throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");
6543
- }
6544
- options.retries ??= 10;
6545
- options.factor ??= 2;
6546
- options.minTimeout ??= 1e3;
6547
- options.maxTimeout ??= Number.POSITIVE_INFINITY;
6548
- options.maxRetryTime ??= Number.POSITIVE_INFINITY;
6549
- options.randomize ??= false;
6550
- options.onFailedAttempt ??= () => {
6551
- };
6552
- options.shouldRetry ??= () => true;
6553
- options.shouldConsumeRetry ??= () => true;
6554
- validateNumberOption("factor", options.factor, { min: 0, allowInfinity: false });
6555
- validateNumberOption("minTimeout", options.minTimeout, { min: 0, allowInfinity: false });
6556
- validateNumberOption("maxTimeout", options.maxTimeout, { min: 0, allowInfinity: true });
6557
- validateNumberOption("maxRetryTime", options.maxRetryTime, { min: 0, allowInfinity: true });
6558
- if (!(options.factor > 0)) {
6559
- options.factor = 1;
6560
- }
6561
- options.signal?.throwIfAborted();
6562
- let attemptNumber = 0;
6563
- let retriesConsumed = 0;
6564
- const startTime = performance.now();
6565
- while (Number.isFinite(options.retries) ? retriesConsumed <= options.retries : true) {
6566
- attemptNumber++;
6567
- try {
6568
- options.signal?.throwIfAborted();
6569
- const result = await input(attemptNumber);
6570
- options.signal?.throwIfAborted();
6571
- return result;
6572
- } catch (error) {
6573
- if (await onAttemptFailure({
6574
- error,
6575
- attemptNumber,
6576
- retriesConsumed,
6577
- startTime,
6578
- options
6579
- })) {
6580
- retriesConsumed++;
6581
- }
6582
- }
6583
- }
6584
- throw new Error("Retry attempts exhausted without throwing an error.");
6630
+
6631
+ var hasRequiredPRetry;
6632
+
6633
+ function requirePRetry () {
6634
+ if (hasRequiredPRetry) return pRetry.exports;
6635
+ hasRequiredPRetry = 1;
6636
+ const retry = requireRetry();
6637
+ const networkErrorMsgs = [
6638
+ "Failed to fetch",
6639
+ // Chrome
6640
+ "NetworkError when attempting to fetch resource.",
6641
+ // Firefox
6642
+ "The Internet connection appears to be offline.",
6643
+ // Safari
6644
+ "Network request failed"
6645
+ // `cross-fetch`
6646
+ ];
6647
+ class AbortError extends Error {
6648
+ constructor(message) {
6649
+ super();
6650
+ if (message instanceof Error) {
6651
+ this.originalError = message;
6652
+ ({ message } = message);
6653
+ } else {
6654
+ this.originalError = new Error(message);
6655
+ this.originalError.stack = this.stack;
6656
+ }
6657
+ this.name = "AbortError";
6658
+ this.message = message;
6659
+ }
6660
+ }
6661
+ const decorateErrorWithCounts = (error, attemptNumber, options) => {
6662
+ const retriesLeft = options.retries - (attemptNumber - 1);
6663
+ error.attemptNumber = attemptNumber;
6664
+ error.retriesLeft = retriesLeft;
6665
+ return error;
6666
+ };
6667
+ const isNetworkError = (errorMessage) => networkErrorMsgs.includes(errorMessage);
6668
+ const pRetry$1 = (input, options) => new Promise((resolve, reject) => {
6669
+ options = {
6670
+ onFailedAttempt: () => {
6671
+ },
6672
+ retries: 10,
6673
+ ...options
6674
+ };
6675
+ const operation = retry.operation(options);
6676
+ operation.attempt(async (attemptNumber) => {
6677
+ try {
6678
+ resolve(await input(attemptNumber));
6679
+ } catch (error) {
6680
+ if (!(error instanceof Error)) {
6681
+ reject(new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`));
6682
+ return;
6683
+ }
6684
+ if (error instanceof AbortError) {
6685
+ operation.stop();
6686
+ reject(error.originalError);
6687
+ } else if (error instanceof TypeError && !isNetworkError(error.message)) {
6688
+ operation.stop();
6689
+ reject(error);
6690
+ } else {
6691
+ decorateErrorWithCounts(error, attemptNumber, options);
6692
+ try {
6693
+ await options.onFailedAttempt(error);
6694
+ } catch (error2) {
6695
+ reject(error2);
6696
+ return;
6697
+ }
6698
+ if (!operation.retry(error)) {
6699
+ reject(operation.mainError());
6700
+ }
6701
+ }
6702
+ }
6703
+ });
6704
+ });
6705
+ pRetry.exports = pRetry$1;
6706
+ pRetry.exports.default = pRetry$1;
6707
+ pRetry.exports.AbortError = AbortError;
6708
+ return pRetry.exports;
6585
6709
  }
6586
6710
 
6711
+ var pRetryExports = requirePRetry();
6712
+ var ai = /*@__PURE__*/getDefaultExportFromCjs(pRetryExports);
6713
+
6587
6714
  var Yn = Object.defineProperty;
6588
6715
  var s = (e, t) => Yn(e, "name", { value: t, configurable: true });
6589
6716
  const st = BigInt(2 ** 32 - 1), Ar = BigInt(32);
@@ -9463,9 +9590,9 @@ function Wn({ sensitiveValues: e, step: t }) {
9463
9590
  }
9464
9591
  s(Wn, "extractStep");
9465
9592
  async function La({ fileData: e, maxRetries: t = 3, uploadUrl: r }) {
9466
- await pRetry(async () => {
9593
+ await ai(async () => {
9467
9594
  const n = await fetch(r, { body: e, method: "PUT" });
9468
- if (!n.ok) throw n.status >= 400 && n.status < 500 ? new AbortError(`Upload failed with status ${n.status}: ${n.statusText}`) : new Error(`Upload failed with status ${n.status}: ${n.statusText}`);
9595
+ if (!n.ok) throw n.status >= 400 && n.status < 500 ? new pRetryExports.AbortError(`Upload failed with status ${n.status}: ${n.statusText}`) : new Error(`Upload failed with status ${n.status}: ${n.statusText}`);
9469
9596
  }, { minTimeout: 2e3, randomize: true, retries: t });
9470
9597
  }
9471
9598
  s(La, "uploadWithRetry");
@@ -9652,4 +9779,4 @@ function xa(e) {
9652
9779
  s(xa, "stablyReporter");
9653
9780
 
9654
9781
  export { Vn as V, xa as x };
9655
- //# sourceMappingURL=index-BklBJUIC.mjs.map
9782
+ //# sourceMappingURL=index-Tn_eFdjz.mjs.map