×ばつ 500ms = 500 seconds (8+ minutes) of background execution even after the main promise resolved. Solution Two-part fix implemented: Added a stop flag: Introduced shouldStop boolean to signal the promiseRetry to stop when the race resolves Reduced aggressive retry settings: Changed from {retries: 1000, minTimeout: 500, maxTimeout: 500, factor: 1} to {retries: 10, minTimeout: 100, maxTimeout: 500, factor: 1.5} which provides reasonable retry behavior with exponential backoff The fix is minimal, surgical, and maintains all existing functionality while eliminating the problematic delay. Fixes #4999. 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.">
Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[WIP] Playwright: I.waitForText() causes unexpected delay equal to waitForTimeout value at the end of test suite #5077

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
kobenguyent merged 2 commits into 3.x from copilot/fix-4999
Aug 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions lib/helper/Playwright.js
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}

/**
Expand Down
Loading

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