Skip to content

Commit 7405d65

Browse files
authored
chore: do not continue with no_reply messages (microsoft#1905)
1 parent b913f48 commit 7405d65

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

playwright/_impl/_connection.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ async def send_return_as_dict(self, method: str, params: Dict = None) -> Any:
6868
)
6969

7070
def send_no_reply(self, method: str, params: Dict = None) -> None:
71+
# No reply messages are used to e.g. waitForEventInfo(after).
7172
self._connection.wrap_api_call_sync(
7273
lambda: self._connection._send_message_to_server(
73-
self._guid, method, {} if params is None else params
74+
self._guid, method, {} if params is None else params, True
7475
)
7576
)
7677

@@ -178,6 +179,7 @@ def remove_listener(self, event: str, f: Any) -> None:
178179
class ProtocolCallback:
179180
def __init__(self, loop: asyncio.AbstractEventLoop) -> None:
180181
self.stack_trace: traceback.StackSummary
182+
self.no_reply: bool
181183
self.future = loop.create_future()
182184
# The outer task can get cancelled by the user, this forwards the cancellation to the inner task.
183185
current_task = asyncio.current_task()
@@ -305,7 +307,7 @@ def set_in_tracing(self, is_tracing: bool) -> None:
305307
self._tracing_count -= 1
306308

307309
def _send_message_to_server(
308-
self, guid: str, method: str, params: Dict
310+
self, guid: str, method: str, params: Dict, no_reply: bool = False
309311
) -> ProtocolCallback:
310312
if self._closed_error_message:
311313
raise Error(self._closed_error_message)
@@ -317,6 +319,7 @@ def _send_message_to_server(
317319
traceback.StackSummary,
318320
getattr(task, "__pw_stack_trace__", traceback.extract_stack()),
319321
)
322+
callback.no_reply = no_reply
320323
self._callbacks[id] = callback
321324
stack_trace_information = cast(ParsedStackTrace, self._api_zone.get())
322325
frames = stack_trace_information.get("frames", [])
@@ -357,6 +360,10 @@ def dispatch(self, msg: ParsedMessagePayload) -> None:
357360
callback = self._callbacks.pop(id)
358361
if callback.future.cancelled():
359362
return
363+
# No reply messages are used to e.g. waitForEventInfo(after) which returns exceptions on page close.
364+
# To prevent 'Future exception was never retrieved' we just ignore such messages.
365+
if callback.no_reply:
366+
return
360367
error = msg.get("error")
361368
if error:
362369
parsed_error = parse_error(error["error"]) # type: ignore

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy