@@ -47,9 +47,15 @@ async def inner_send(
47
47
if params is None :
48
48
params = {}
49
49
callback = self ._connection ._send_message_to_server (self ._guid , method , params )
50
-
51
- done , pending = await asyncio .wait (
52
- {self ._connection ._transport .on_error_future , callback .future },
50
+ if self ._connection ._error :
51
+ error = self ._connection ._error
52
+ self ._connection ._error = None
53
+ raise error
54
+ done , _ = await asyncio .wait (
55
+ {
56
+ self ._connection ._transport .on_error_future ,
57
+ callback .future ,
58
+ },
53
59
return_when = asyncio .FIRST_COMPLETED ,
54
60
)
55
61
if not callback .future .done ():
@@ -152,10 +158,10 @@ def __init__(
152
158
self ._callbacks : Dict [int , ProtocolCallback ] = {}
153
159
self ._object_factory = object_factory
154
160
self ._is_sync = False
155
- self ._api_name = ""
156
161
self ._child_ws_connections : List ["Connection" ] = []
157
162
self ._loop = loop
158
163
self ._playwright_future : asyncio .Future ["Playwright" ] = loop .create_future ()
164
+ self ._error : Optional [BaseException ] = None
159
165
160
166
async def run_as_sync (self ) -> None :
161
167
self ._is_sync = True
@@ -260,11 +266,10 @@ def _dispatch(self, msg: ParsedMessagePayload) -> None:
260
266
g .switch (self ._replace_guids_with_channels (params ))
261
267
else :
262
268
object ._channel .emit (method , self ._replace_guids_with_channels (params ))
263
- except Exception :
264
- print (
265
- "Error dispatching the event" ,
266
- "" .join (traceback .format_exception (* sys .exc_info ())),
267
- )
269
+ except BaseException as exc :
270
+ print ("Error occured in event listener" , file = sys .stderr )
271
+ traceback .print_exc ()
272
+ self ._error = exc
268
273
269
274
def _create_remote_object (
270
275
self , parent : ChannelOwner , type : str , guid : str , initializer : Dict
0 commit comments