Skip to content

fix(waiter): propagate async predicate cancellation - #3381

Draft
microsoft-playwright-automation[bot] wants to merge 2 commits into
mainfrom
triage/3379/45794865091-1
Draft

microsoft-playwright-automation[bot] wants to merge 2 commits into
mainfrom
triage/3379/45794865091-1

Conversation

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor
  • An async predicate's CancelledError bypasses except Exception, leaving its event future pending. Remove the listener and settle the future with the cancellation before re-raising it in the predicate task.
  • Use the explicit cancellation handling also proposed in fix: handle cancellation in async event predicates #3380. Extend the existing async-predicate error test with a cancellation case and a listener-cleanup assertion.

Verified on Linux with Python 3.12.3: the regression fails without the fix and passes on Chromium, Firefox and headed WebKit. Neighboring async/sync checks pass (155 passed, 2 existing headless-only skips), as do mypy playwright and ./scripts/lint.sh. Headless WebKit could not create an EGL display.

Fixes #3379

Triaged on Linux by the Playwright bot - agent run

@dgozman

Copy link
Copy Markdown
Collaborator

This PR is failing many tests. Please list them here and check whether any of them are related to the change being made.

@microsoft-playwright-automation

This comment has been minimized.

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor Author

Hi, I'm the Playwright bot. I checked the full CI logs and compared the failures with main.

This PR causes the new cancellation test to fail in seven Python 3.10 jobs. All other failed tests also fail or flake on main. CI run 45797362887 has 15 final test failures across ten jobs, grouped below. Retries that eventually passed are not counted.

All failed tests and their relation to this PR

Caused by this PR

tests/async/python/test_page.py::test_expect_response_should_reject_when_async_predicate_throws[chromium-CancelledError] fails in seven jobs:

  • Chromium on Linux, Windows and macOS with Python 3.10.
  • Stable Chrome on Linux, Windows and macOS, and stable Edge on Windows; these jobs also use Python 3.10.

The test receives CancelledError, not a timeout, but its message is empty at AsyncEventInfo.value. The new match="Async oops!" assertion therefore fails. The predicate traceback still shows CancelledError: Async oops!. This is a test assertion problem on Python 3.10, not evidence that cancellation still hangs. A focused correction is to check the message only for Exception, while keeping the cancellation-type and listener-cleanup checks.

Pre-existing failures / flakes

Failed test PR jobs and failure Evidence without this PR
tests/sync/library/test_capabilities.py::test_CA_020_request_fullscreen[webkit] Windows and macOS, Python 3.12. Windows: InvalidStateError instead of success; macOS: pytest worker crash. Both failures occur on the exact PR base, f31e702, in main run 45605502658.
tests/async/library/test_capabilities.py::test_CA_020_request_fullscreen[webkit] The same Windows and macOS jobs, with the same errors. Both also occur in that main run.
tests/sync/library/test_video.py::test_VI_030_screencast_should_work_with_video_trace[chromium] Linux, Python 3.14: IndexError because the trace has no screencast-frame. Same test and error on Linux Python 3.14 in main run 45362401896, commit 8b45251; passed on retry.
tests/async/library/test_video.py::test_VI_030_screencast_should_work_with_video_trace[chromium] Linux, Python 3.14: the same missing-frame IndexError. Same test and error on Linux Python 3.14 at the PR base in main run 45605502658; passed on retry.
tests/sync/page/test_page_screenshot.py::test_SS_025_page_screenshot_should_work_for_webgl[chromium] macOS stable Chrome: screenshot differs by 38,160 pixels. Same test, channel, platform and pixel count in main run 44775908845, commit de03c86.
tests/sync/page/test_page_screenshot.py::test_SS_095_page_screenshot_should_capture_webgl_canvas_after_its_drawing_buffer_is_resized[chromium] macOS stable Chrome: WebGL context is null; reading canvas throws. Same test and error in that main run.

These six test cases do not use an async predicate that raises CancelledError, so they do not exercise the changed branch in waiter.py.

No code changes were made: this revision answers the investigation request. The PR is already on current main (f31e702). I used the recorded CI results; I did not rebuild or rerun the tests locally.

Revised on Linux by the Playwright bot - agent run

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

@dgozman Dmitry Gozman (dgozman) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's skip the failing version of the new test on python 3.10.

@dgozman Dmitry Gozman (dgozman) added agent-review and removed agent-review-done The Playwright bot run ended labels Nov 26, 2026
@microsoft-playwright-automation

This comment has been minimized.

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor Author

Hi, I'm the Playwright bot and I skipped only the new CancelledError case on Python 3.10, as requested. The ordinary Exception case still runs there; both cases still run on Python 3.11 and later.

Verified with Python 3.10.22 on Chromium, Firefox and headed WebKit: 3 passed, 3 skipped. On Python 3.12.3, the changed file and neighboring async/sync wait tests passed: 115 passed, 2 existing headless-only skips. The cancellation regression still fails without the fix and passes with it. ./scripts/lint.sh passed.

WebKit used locally extracted libraries and ran headed under Xvfb; headless WebKit closed before creating a page. Windows and macOS were not tested.

Revised on Linux by the Playwright bot - agent run

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

This branch has not been deployed

No deployments
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]: Async event predicate raising CancelledError leaves the event waiter pending

1 participant