From 1086c730fe9246e863238d6f292c33e36278f382 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+copilot@users.noreply.github.com> Date: 2025年8月20日 04:48:11 +0000 Subject: [PATCH 1/2] Initial plan From c227ffa70a3451149928e723d874f63722448d67 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+copilot@users.noreply.github.com> Date: 2025年8月20日 05:03:02 +0000 Subject: [PATCH 2/2] Changes before error encountered Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com> --- lib/helper/Playwright.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/helper/Playwright.js b/lib/helper/Playwright.js index dfc7b855d..ef91c8d67 100644 --- a/lib/helper/Playwright.js +++ b/lib/helper/Playwright.js @@ -2801,22 +2801,37 @@ class Playwright extends Helper { // We apply 2 strategies here: wait for text as innert text on page (wide strategy) - older // or we use native Playwright matcher to wait for text in element (narrow strategy) - newer // If a user waits for text on a page they are mostly expect it to be there, so wide strategy can be helpful even PW strategy is available - return Promise.race([ + + // Use a flag to stop retries when race resolves + let shouldStop = false + let timeoutId + + const racePromise = Promise.race([ new Promise((_, reject) => { - setTimeout(() => reject(errorMessage), waitTimeout) + timeoutId = setTimeout(() => reject(errorMessage), waitTimeout) }), this.page.waitForFunction(text => document.body && document.body.innerText.indexOf(text)> -1, text, { timeout: timeoutGap }), promiseRetry( - async retry => { + async (retry, number) => { + // Stop retrying if race has resolved + if (shouldStop) { + throw new Error('Operation cancelled') + } const textPresent = await contextObject .locator(`:has-text(${JSON.stringify(text)})`) .first() .isVisible() if (!textPresent) retry(errorMessage) }, - { retries: 1000, minTimeout: 500, maxTimeout: 500, factor: 1 }, + { retries: 10, minTimeout: 100, maxTimeout: 500, factor: 1.5 }, ), ]) + + // Clean up when race resolves/rejects + return racePromise.finally(() => { + if (timeoutId) clearTimeout(timeoutId) + shouldStop = true + }) } /**

AltStyle によって変換されたページ (->オリジナル) /