Skip to content

fix(locator): [breaking] await waitForFunction predicate promises - #44220

Merged
Devin Rousso (dcrousso) merged 2 commits into
mainfrom
triage/44217/44370243233-1
Nov 19, 2026
Merged

Devin Rousso (dcrousso) merged 2 commits into
mainfrom
triage/44217/44370243233-1

Conversation

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor

Locator.waitForFunction checked a returned promise for truthiness instead of awaiting its value, so async predicates passed immediately and rejections were lost.

Await the element callback before checking its result. Extend the existing promise and error tests to cover false results, delayed resolution with polling, and rejection.

Fixes #44217

Triaged on Linux by the Playwright bot - agent run

@github-actions

This comment has been minimized.

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor Author

🟢 All three failures predate this PR

Hi, I'm the Playwright bot. I checked the failed MCP run against main; the same three Chrome tests fail there with the same errors.

Failure details and evidence

Covers MCP run 44371924193 at 9263475dc361. No failure points to the promise-awaiting change.

Pre-existing flake / infra

All three tests in mcp/crash.spec.ts, project chrome, also fail in this main-branch job at 51d5cd20bb16:

Test Same error in both runs
:31 — reports the navigation error, then resets and logs the crash 30-second timeout in the snapshot/reset check at line 48.
:58 — lists only one tab 30-second timeout and Not connected during browser_tabs at line 71.
:79 — marks non-current crashed tab in the tab list 30-second timeout and Not connected during browser_tabs at line 93.

That main commit is an ancestor of this PR and does not contain its fix. The crash tests and MCP navigation/tab code are unchanged. This establishes that the failures already existed; it does not establish that they are intermittent. No fix is proposed here.

Checked the failures on Linux by the Playwright bot - agent run

@github-actions

This comment has been minimized.

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor Author

🟢 Both Windows JUnit failures predate this PR

Hi, I'm the Playwright bot. The same two tests fail with identical errors on main, at this PR's parent commit.

Failure details and evidence

Covers tests 1 run 44371923980 at 9263475dc361. The locator predicate change does not affect these reporter tests.

Pre-existing flake / infra

[playwright-test] › reporter-junit.spec.ts:350 › should add file attribute relative to fileRoot, both created and merged, fails in the PR's Windows job and the main-branch Windows job at 51d5cd20bb16, the PR's parent:

reporter-junit.spec.ts:374
Expected: "auth/a.test.js"
Received: "auth\\a.test.js"

This is a pre-existing Windows assertion mismatch, not evidence of an intermittent flake. JUnit classname uses the native suite path; only the new file attribute is converted to forward slashes. The reporter and these tests are unchanged by this PR, and their inline test does not use a browser.

A small test-only fix is to expect path.join('auth', 'a.test.js') for byDefault['classname']. Keep the file assertions unchanged.

The MCP failures already have a separate verdict above.

Checked the failures on Linux by the Playwright bot - agent run

@dcrousso
Devin Rousso (dcrousso) marked this pull request as ready for review November 18, 2026 20:56
@pavelfeldman Pavel Feldman (pavelfeldman) changed the title fix(locator): await waitForFunction predicate promises fix(locator): [breaking] await waitForFunction predicate promises Nov 19, 2026
});

it('LO-189 should throw when predicate throws', async ({ page }) => {
it('LO-189 should throw when predicate throws', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/44217' } }, async ({ page }) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a separate test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved async rejection coverage into its own issue-tagged test, LO-200, and restored the synchronous throw test. Both regression tests fail without the fix and pass with it on all three browsers; the build, repository checks, and 126 affected and neighboring tests pass.

Revised on Linux by the Playwright bot - agent run

@microsoft-playwright-automation

This comment has been minimized.

@microsoft-playwright-automation microsoft-playwright-automation Bot added agent-review-done The Playwright bot run ended and removed agent-review labels Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

3 failed
❌ [chrome] › mcp/crash.spec.ts:31 › crash recovery › reports the navigation error, then resets and logs the crash @mcp-ubuntu-latest-chrome
❌ [chrome] › mcp/crash.spec.ts:58 › crash recovery › lists only one tab @mcp-ubuntu-latest-chrome
❌ [chrome] › mcp/crash.spec.ts:79 › crash recovery › marks non-current crashed tab in the tab list @mcp-ubuntu-latest-chrome

5243 passed, 641 skipped


Merge workflow run.

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor Author

🟢 All three MCP failures predate this PR

Hi, I'm the Playwright bot. I compared this run with main at the PR's exact base commit; all three tests fail there with the same errors.

Failure details and evidence

Covers MCP run 44563306303 at b43f6f7f93e4.

Pre-existing flake / infra

The PR's Ubuntu Chrome job and the main-branch Ubuntu Chrome job have identical failures in [chrome] › mcp/crash.spec.ts › crash recovery:

Test Error in both jobs
:31 — reports the navigation error, then resets and logs the crash 30-second timeout in the snapshot/reset check at line 48.
:58 — lists only one tab 30-second timeout and Not connected during browser_tabs at line 71.
:79 — marks non-current crashed tab in the tab list 30-second timeout and Not connected during browser_tabs at line 93.

The main run tests ff7cf8ebdb38, the base immediately before this PR's two commits. It contains neither the promise-awaiting fix nor its tests. The crash-recovery tests are unchanged by this PR.

These are confirmed pre-existing failures, not evidence against this PR. This comparison does not establish that they are intermittent, and the logs do not establish a trivial fix.

Checked the failures on Linux - agent run

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

2 failed
❌ [playwright-test] › reporter-junit.spec.ts:350 › created › should add file attribute relative to fileRoot @playwright-x64-server2025-64-core-node22
❌ [playwright-test] › reporter-junit.spec.ts:350 › merged › should add file attribute relative to fileRoot @playwright-x64-server2025-64-core-node22

2 flaky ⚠️ [chromium-library] › library/popup.spec.ts:279 › PO-028 should not throw when click closes popup `@chromium-playwright-x64-ubuntu24-64-core-node22`
⚠️ [firefox-page] › page/page-event-pageerror.spec.ts:289 › ER-022 should not fire for a caught fetch rejected by a pending navigation `@firefox-playwright-x64-ubuntu24-64-core-node22`

23650 passed, 716 skipped


Merge workflow run.

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor Author

🟢 Both Windows JUnit failures predate this PR

Hi, I'm the Playwright bot. These two tests already failed on main; their test code and reporter code are unchanged since that baseline.

Failure details and evidence

Covers tests 1 run 44563307159 at b43f6f7f93e4. The PR changes locator predicate handling, its tests, and the test registry, not JUnit reporting.

Pre-existing flake / infra

Both [playwright-test] › reporter-junit.spec.ts:350 › should add file attribute relative to fileRoot variants, created and merged, fail in the PR's Windows job.

The earlier investigation confirmed both failures in this main-branch Windows job at 51d5cd20bb16:

reporter-junit.spec.ts:374
Expected: "auth/a.test.js"
Received: "auth\\a.test.js"

I verified that commit is an ancestor of this PR and that reporter-junit.spec.ts and reporters/junit.ts are identical between that commit and the current PR head. This is a pre-existing Windows assertion mismatch, not evidence of an intermittent flake. classname preserves the native path; only the file attribute is converted to forward slashes.

The small test-only fix remains to expect path.join('auth', 'a.test.js') for byDefault['classname'], leaving the file assertions unchanged.

Limit: current job logs and artifacts require access unavailable in this run, and the test-history database could not be refreshed. The historical error above comes from the linked investigation, not a fresh download of the current logs.

The two retry-passing tests are not failures. MCP failures at this head already have a separate verdict.

Checked the failures on Linux - agent run

@dcrousso
Devin Rousso (dcrousso) merged commit 09dab5d into main Nov 19, 2026
41 of 43 checks passed
@dcrousso
Devin Rousso (dcrousso) deleted the triage/44217/44370243233-1 branch November 19, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-review-done The Playwright bot run ended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: locator.waitForFunction returns immediately when the predicate returns a Promise

2 participants