Skip to content

Commit 3702bfe

Browse files
committed
fix: ignore waiter telemetry on remote close
1 parent fb4a1a3 commit 3702bfe

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

playwright/_impl/_waiter.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from pyee import EventEmitter
2323

2424
from playwright._impl._connection import ChannelOwner
25-
from playwright._impl._errors import Error, TimeoutError
25+
from playwright._impl._errors import Error, TimeoutError, is_target_closed_error
2626

2727

2828
class Waiter:
@@ -50,20 +50,29 @@ def _wait_for_event_info_before(self, wait_id: str, event: str) -> None:
5050
)
5151

5252
def _wait_for_event_info_after(self, wait_id: str, error: Exception = None) -> None:
53-
self._channel._connection.wrap_api_call_sync(
54-
lambda: self._channel.send_no_reply(
55-
"waitForEventInfo",
56-
None,
57-
{
58-
"info": {
59-
"waitId": wait_id,
60-
"phase": "after",
61-
**({"error": str(error)} if error else {}),
53+
try:
54+
self._channel._connection.wrap_api_call_sync(
55+
lambda: self._channel.send_no_reply(
56+
"waitForEventInfo",
57+
None,
58+
{
59+
"info": {
60+
"waitId": wait_id,
61+
"phase": "after",
62+
**({"error": str(error)} if error else {}),
63+
},
6264
},
63-
},
64-
),
65-
True,
66-
)
65+
),
66+
True,
67+
)
68+
except Error as e:
69+
# This is best-effort telemetry. During remote browser shutdown, the
70+
# waiter result has already been resolved, but the pipe may be closing.
71+
if (
72+
not is_target_closed_error(e)
73+
and e.message != "Playwright connection closed"
74+
):
75+
raise
6776

6877
def reject_on_event(
6978
self,

0 commit comments

Comments
 (0)