@skrillex1224/playwright-toolkit 2.1.256 → 2.1.258

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
@@ -2275,7 +2275,7 @@ async function createApifyKit() {
2275
2275
  options
2276
2276
  }
2277
2277
  );
2278
- await Actor2.fail(`Run Step ${step} \u5931\u8D25 (\u5DF2\u91CD\u8BD5 ${retryTimes} \u6B21): ${finalError.message}`);
2278
+ await Actor2.fail(`Run Step ${step} \u5931\u8D25 (\u5DF2\u91CD\u8BD5 ${retryTimes} \u6B21): ${finalError.message} | url: ${page.url()}`);
2279
2279
  } else {
2280
2280
  throw finalError;
2281
2281
  }
@@ -9041,6 +9041,13 @@ var Share = {
9041
9041
  const domMode = options.domMode ?? Mutation.Mode.All;
9042
9042
  const performActions = typeof options.performActions === "function" ? options.performActions : async () => {
9043
9043
  };
9044
+ const signal = options.signal;
9045
+ const isAborted = () => Boolean(signal?.aborted);
9046
+ const abortReason = () => {
9047
+ const reason = signal?.reason;
9048
+ if (reason instanceof Error) return reason.message;
9049
+ return reason ? String(reason) : "aborted";
9050
+ };
9044
9051
  if (share.prefix === void 0) {
9045
9052
  throw new Error("Share.captureLink requires options.share.prefix");
9046
9053
  }
@@ -9064,6 +9071,15 @@ var Share = {
9064
9071
  lastMatchedUrl: "",
9065
9072
  responseSampleUrls: []
9066
9073
  };
9074
+ if (isAborted()) {
9075
+ logger15.warning(`captureLink \u5DF2\u53D6\u6D88: ${abortReason()}`);
9076
+ return {
9077
+ link: null,
9078
+ payloadText: "",
9079
+ payloadSnapshot: abortReason(),
9080
+ source: "none"
9081
+ };
9082
+ }
9067
9083
  const candidates = {
9068
9084
  dom: null,
9069
9085
  response: null,
@@ -9122,6 +9138,7 @@ var Share = {
9122
9138
  if (candidates.response?.link) return;
9123
9139
  stats.responseObserved += 1;
9124
9140
  try {
9141
+ if (isAborted()) return;
9125
9142
  const url = String(response.url() || "");
9126
9143
  if (url && stats.responseSampleUrls.length < 8 && !stats.responseSampleUrls.includes(url)) {
9127
9144
  stats.responseSampleUrls.push(url);
@@ -9176,7 +9193,7 @@ var Share = {
9176
9193
  const actionTimeout = getRemainingMs();
9177
9194
  logger15.start("captureLink.performActions", `\u6267\u884C\u52A8\u4F5C\u9884\u7B97=${actionTimeout}ms`);
9178
9195
  let actionValue;
9179
- if (actionTimeout > 0) {
9196
+ if (!isAborted() && actionTimeout > 0) {
9180
9197
  let timer = null;
9181
9198
  const actionPromise = Promise.resolve().then(() => performActions()).then((result) => ({ type: "done", result })).catch((error) => ({ type: "error", error }));
9182
9199
  const timeoutPromise = new Promise((resolve) => {
@@ -9207,6 +9224,15 @@ var Share = {
9207
9224
  }
9208
9225
  let nextProgressLogTs = Date.now() + 3e3;
9209
9226
  while (true) {
9227
+ if (isAborted()) {
9228
+ logger15.warning(`captureLink \u5DF2\u53D6\u6D88: ${abortReason()}`);
9229
+ return {
9230
+ link: null,
9231
+ payloadText: "",
9232
+ payloadSnapshot: abortReason(),
9233
+ source: "none"
9234
+ };
9235
+ }
9210
9236
  const selected = candidates[share.mode];
9211
9237
  if (selected?.link) {
9212
9238
  logger15.success("captureLink", `\u6355\u83B7\u6210\u529F: source=${share.mode}, link=${selected.link}`);