[Regression]: pytest.fail() inside an event handler closes the connection
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
レポートの再現スクリプトをローカル checkout に対して実行して現在の失敗を確認し、次に sync API が listener コールバックを dispatch する場所と、listener の例外が捕捉される場所を確認してください。レポートはそれをその catch 節に絞り込んでいます。その節は Exception を処理しており、BaseException のサブクラス(pytest.fail()、pytest.skip()、pytest.xfail() が送出するものなど)を対象に含める必要がありますが、接続を kill しないままにする必要もあります。完了とは、実行が 1 Failed console: hi を出力し、error listener が引き続き発火し、その後もページが使用可能であることを意味します。既存の listener-error テストの隣に回帰テストを追加してください。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Python
- スター
- 15.1k
- フォーク
- 1.3k
- 平均マージ
- 6時間 16分
- マージ済み PR(30日)
- 53
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/playwright-python のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
microsoft/playwright-python#3361 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
microsoft/playwright-python#3362 ·
メンテナーはふだん 1 日以内に返信
microsoft/playwright-python の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
snap-stanford/Biomni#380 ·
-
documentation priority: low size: S status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
cubrid-lab/sqlalchemy-cubrid#1397 ·
メンテナーはふだん 1 日以内に返信
-
documentation priority: low size: S status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
cubrid-lab/pycubrid#1307 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: Installer hides SSL certificate errors as bare URLError, and the suggested fix can't workオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
ShaftHQ/chaosengine-harness#143 ·
メンテナーはふだん 1 日以内に返信
-
bug high-severity
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
aws/bedrock-agentcore-sdk-python#752 ·
メンテナーはふだん 1 日以内に返信