[Regression]: pytest.fail() inside an event handler closes the connection
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 65/100
Hướng nghiên cứu
Chạy script tái hiện từ báo cáo trên một checkout cục bộ để xác nhận lỗi hiện tại, sau đó xem nơi API sync dispatch callback của listener và nơi exception của một listener được bắt. Báo cáo thu hẹp nó vào mệnh đề catch đó: nó xử lý Exception, và cần bao phủ các lớp con của BaseException như những lớp mà pytest.fail(), pytest.skip() và pytest.xfail() ném ra, trong khi vẫn không kill connection. Hoàn tất nghĩa là lần chạy in ra 1 Failed console: hi, listener error vẫn kích hoạt, và trang vẫn dùng được sau đó; thêm một test hồi quy bên cạnh các test lỗi listener hiện có.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Last Good Version
1.64.0
First Bad Version
1.65.0
Steps to reproduce
import pytest
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
page = p.chromium.launch().new_page()
page.on("error", lambda e: print("error listener:", e))
page.on("console", lambda msg: pytest.fail(f"console: {msg.text}"))
for i in range(2):
try:
page.evaluate("console.log('hi')")
print(i, "ok")
except BaseException as e:
print(i, type(e).__name__, str(e).splitlines()[0])
Expected behavior
Same as 1.64:
0 ok
1 Failed console: hi
Actual behavior
0 TargetClosedError Page.evaluate: Target page, context or browser has been closed
1 TargetClosedError Playwright connection closed
The Failed is gone and the connection is dead. The error listener is not called either.
With a plain Exception (e.g. assert False) it still works, so it's only BaseException subclasses — which is what pytest.fail(), pytest.skip() and pytest.xfail() raise. The listener error handling in the dispatch path now catches Exception; before the port it was BaseException.
Additional context
No response
Environment
- Operating System: macOS 27.2
- CPU: arm64
- Browser: Chromium
- Python Version: 3.14
- Other info: sync API
- Ngôn ngữ chính
- Python
- Star
- 15.1k
- Fork
- 1.3k
- Merge trung bình
- 6 giờ 16 phút
- Pull request đã merge (30 ngày)
- 53
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/playwright-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
microsoft/playwright-python#3361 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
microsoft/playwright-python#3362 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/playwright-python
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
snap-stanford/Biomni#380 ·
-
documentation priority: low size: S status: needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
cubrid-lab/sqlalchemy-cubrid#1397 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation priority: low size: S status: needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
cubrid-lab/pycubrid#1307 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Installer hides SSL certificate errors as bare URLError, and the suggested fix can't workĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
ShaftHQ/chaosengine-harness#143 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug high-severity
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
aws/bedrock-agentcore-sdk-python#752 ·
Maintainer thường phản hồi trong vòng 1 ngày