Skip to content

Commit 578f533

Browse files
committed
chore: explicit timeout config for send
1 parent b3e5199 commit 578f533

26 files changed

+482
-228
lines changed

playwright/_impl/_accessibility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@ async def snapshot(
6565
params = locals_to_params(locals())
6666
if root:
6767
params["root"] = root._channel
68-
result = await self._channel.send("accessibilitySnapshot", params)
68+
result = await self._channel.send("accessibilitySnapshot", None, params)
6969
return _ax_node_from_protocol(result) if result else None

playwright/_impl/_artifact.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,55 @@ async def path_after_finished(self) -> pathlib.Path:
3333
raise Error(
3434
"Path is not available when using browser_type.connect(). Use save_as() to save a local copy."
3535
)
36-
path = await self._channel.send("pathAfterFinished")
36+
path = await self._channel.send(
37+
"pathAfterFinished",
38+
None,
39+
)
3740
return pathlib.Path(path)
3841

3942
async def save_as(self, path: Union[str, Path]) -> None:
40-
stream = cast(Stream, from_channel(await self._channel.send("saveAsStream")))
43+
stream = cast(
44+
Stream,
45+
from_channel(
46+
await self._channel.send(
47+
"saveAsStream",
48+
None,
49+
)
50+
),
51+
)
4152
make_dirs_for_file(path)
4253
await stream.save_as(path)
4354

4455
async def failure(self) -> Optional[str]:
45-
reason = await self._channel.send("failure")
56+
reason = await self._channel.send(
57+
"failure",
58+
None,
59+
)
4660
if reason is None:
4761
return None
4862
return patch_error_message(reason)
4963

5064
async def delete(self) -> None:
51-
await self._channel.send("delete")
65+
await self._channel.send(
66+
"delete",
67+
None,
68+
)
5269

5370
async def read_info_buffer(self) -> bytes:
54-
stream = cast(Stream, from_channel(await self._channel.send("stream")))
71+
stream = cast(
72+
Stream,
73+
from_channel(
74+
await self._channel.send(
75+
"stream",
76+
None,
77+
)
78+
),
79+
)
5580
buffer = await stream.read_all()
5681
return buffer
5782

5883
async def cancel(self) -> None: # pyright: ignore[reportIncompatibleMethodOverride]
59-
await self._channel.send("cancel")
84+
await self._channel.send(
85+
"cancel",
86+
None,
87+
)

playwright/_impl/_browser.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ async def new_context(
173173
if self._browser_type:
174174
await self._browser_type._prepare_browser_context_params(params)
175175

176-
channel = await self._channel.send("newContext", params)
176+
channel = await self._channel.send("newContext", None, params)
177177
context = cast(BrowserContext, from_channel(channel))
178178
await context._initialize_har_from_options(
179179
record_har_content=recordHarContent,
@@ -240,7 +240,7 @@ async def close(self, reason: str = None) -> None:
240240
if self._should_close_connection_on_close:
241241
await self._connection.stop_async()
242242
else:
243-
await self._channel.send("close", {"reason": reason})
243+
await self._channel.send("close", None, {"reason": reason})
244244
except Exception as e:
245245
if not is_target_closed_error(e):
246246
raise e
@@ -250,7 +250,7 @@ def version(self) -> str:
250250
return self._initializer["version"]
251251

252252
async def new_browser_cdp_session(self) -> CDPSession:
253-
return from_channel(await self._channel.send("newBrowserCDPSession"))
253+
return from_channel(await self._channel.send("newBrowserCDPSession", None))
254254

255255
async def start_tracing(
256256
self,
@@ -265,10 +265,12 @@ async def start_tracing(
265265
if path:
266266
self._cr_tracing_path = str(path)
267267
params["path"] = str(path)
268-
await self._channel.send("startTracing", params)
268+
await self._channel.send("startTracing", None, params)
269269

270270
async def stop_tracing(self) -> bytes:
271-
artifact = cast(Artifact, from_channel(await self._channel.send("stopTracing")))
271+
artifact = cast(
272+
Artifact, from_channel(await self._channel.send("stopTracing", None))
273+
)
272274
buffer = await artifact.read_info_buffer()
273275
await artifact.delete()
274276
if self._cr_tracing_path:

playwright/_impl/_browser_context.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -330,17 +330,17 @@ async def _initialize_har_from_options(
330330
async def new_page(self) -> Page:
331331
if self._owner_page:
332332
raise Error("Please use browser.new_context()")
333-
return from_channel(await self._channel.send("newPage"))
333+
return from_channel(await self._channel.send("newPage", None))
334334

335335
async def cookies(self, urls: Union[str, Sequence[str]] = None) -> List[Cookie]:
336336
if urls is None:
337337
urls = []
338338
if isinstance(urls, str):
339339
urls = [urls]
340-
return await self._channel.send("cookies", dict(urls=urls))
340+
return await self._channel.send("cookies", None, dict(urls=urls))
341341

342342
async def add_cookies(self, cookies: Sequence[SetCookieParam]) -> None:
343-
await self._channel.send("addCookies", dict(cookies=cookies))
343+
await self._channel.send("addCookies", None, dict(cookies=cookies))
344344

345345
async def clear_cookies(
346346
self,
@@ -350,6 +350,7 @@ async def clear_cookies(
350350
) -> None:
351351
await self._channel.send(
352352
"clearCookies",
353+
None,
353354
{
354355
"name": name if isinstance(name, str) else None,
355356
"nameRegexSource": name.pattern if isinstance(name, Pattern) else None,
@@ -374,21 +375,21 @@ async def clear_cookies(
374375
async def grant_permissions(
375376
self, permissions: Sequence[str], origin: str = None
376377
) -> None:
377-
await self._channel.send("grantPermissions", locals_to_params(locals()))
378+
await self._channel.send("grantPermissions", None, locals_to_params(locals()))
378379

379380
async def clear_permissions(self) -> None:
380-
await self._channel.send("clearPermissions")
381+
await self._channel.send("clearPermissions", None)
381382

382383
async def set_geolocation(self, geolocation: Geolocation = None) -> None:
383-
await self._channel.send("setGeolocation", locals_to_params(locals()))
384+
await self._channel.send("setGeolocation", None, locals_to_params(locals()))
384385

385386
async def set_extra_http_headers(self, headers: Dict[str, str]) -> None:
386387
await self._channel.send(
387-
"setExtraHTTPHeaders", dict(headers=serialize_headers(headers))
388+
"setExtraHTTPHeaders", None, dict(headers=serialize_headers(headers))
388389
)
389390

390391
async def set_offline(self, offline: bool) -> None:
391-
await self._channel.send("setOffline", dict(offline=offline))
392+
await self._channel.send("setOffline", None, dict(offline=offline))
392393

393394
async def add_init_script(
394395
self, script: str = None, path: Union[str, Path] = None
@@ -397,7 +398,7 @@ async def add_init_script(
397398
script = (await async_readfile(path)).decode()
398399
if not isinstance(script, str):
399400
raise Error("Either path or script parameter must be specified")
400-
await self._channel.send("addInitScript", dict(source=script))
401+
await self._channel.send("addInitScript", None, dict(source=script))
401402

402403
async def expose_binding(
403404
self, name: str, callback: Callable, handle: bool = None
@@ -411,7 +412,7 @@ async def expose_binding(
411412
raise Error(f'Function "{name}" has been already registered')
412413
self._bindings[name] = callback
413414
await self._channel.send(
414-
"exposeBinding", dict(name=name, needsHandle=handle or False)
415+
"exposeBinding", None, dict(name=name, needsHandle=handle or False)
415416
)
416417

417418
async def expose_function(self, name: str, callback: Callable) -> None:
@@ -499,7 +500,7 @@ async def _record_into_har(
499500
}
500501
if page:
501502
params["page"] = page._channel
502-
har_id = await self._channel.send("harStart", params)
503+
har_id = await self._channel.send("harStart", None, params)
503504
self._har_recorders[har_id] = {
504505
"path": str(har),
505506
"content": update_content,
@@ -535,15 +536,15 @@ async def route_from_har(
535536
async def _update_interception_patterns(self) -> None:
536537
patterns = RouteHandler.prepare_interception_patterns(self._routes)
537538
await self._channel.send(
538-
"setNetworkInterceptionPatterns", {"patterns": patterns}
539+
"setNetworkInterceptionPatterns", None, {"patterns": patterns}
539540
)
540541

541542
async def _update_web_socket_interception_patterns(self) -> None:
542543
patterns = WebSocketRouteHandler.prepare_interception_patterns(
543544
self._web_socket_routes
544545
)
545546
await self._channel.send(
546-
"setWebSocketInterceptionPatterns", {"patterns": patterns}
547+
"setWebSocketInterceptionPatterns", None, {"patterns": patterns}
547548
)
548549

549550
def expect_event(
@@ -596,7 +597,7 @@ async def _inner_close() -> None:
596597
har = cast(
597598
Artifact,
598599
from_channel(
599-
await self._channel.send("harExport", {"harId": har_id})
600+
await self._channel.send("harExport", None, {"harId": har_id})
600601
),
601602
)
602603
# Server side will compress artifact if content is attach or if file is .zip.
@@ -615,14 +616,14 @@ async def _inner_close() -> None:
615616
await har.delete()
616617

617618
await self._channel._connection.wrap_api_call(_inner_close, True)
618-
await self._channel.send("close", {"reason": reason})
619+
await self._channel.send("close", None, {"reason": reason})
619620
await self._closed_future
620621

621622
async def storage_state(
622623
self, path: Union[str, Path] = None, indexedDB: bool = None
623624
) -> StorageState:
624625
result = await self._channel.send_return_as_dict(
625-
"storageState", {"indexedDB": indexedDB}
626+
"storageState", None, {"indexedDB": indexedDB}
626627
)
627628
if path:
628629
await async_writefile(path, json.dumps(result))
@@ -749,7 +750,7 @@ async def new_cdp_session(self, page: Union[Page, Frame]) -> CDPSession:
749750
params["frame"] = page._channel
750751
else:
751752
raise Error("page: expected Page or Frame")
752-
return from_channel(await self._channel.send("newCDPSession", params))
753+
return from_channel(await self._channel.send("newCDPSession", None, params))
753754

754755
@property
755756
def tracing(self) -> Tracing:

playwright/_impl/_browser_type.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async def launch(
9393
params = locals_to_params(locals())
9494
normalize_launch_params(params)
9595
browser = cast(
96-
Browser, from_channel(await self._channel.send("launch", params))
96+
Browser, from_channel(await self._channel.send("launch", None, params))
9797
)
9898
browser._connect_to_browser_type(
9999
self, str(tracesDir) if tracesDir is not None else None
@@ -159,7 +159,7 @@ async def launch_persistent_context(
159159
await self._prepare_browser_context_params(params)
160160
normalize_launch_params(params)
161161
result = await self._channel.send_return_as_dict(
162-
"launchPersistentContext", params
162+
"launchPersistentContext", None, params
163163
)
164164
browser = cast(
165165
Browser,
@@ -200,7 +200,9 @@ async def connect_over_cdp(
200200
params["timeout"] = TimeoutSettings.launch_timeout(timeout)
201201
if params.get("headers"):
202202
params["headers"] = serialize_headers(params["headers"])
203-
response = await self._channel.send_return_as_dict("connectOverCDP", params)
203+
response = await self._channel.send_return_as_dict(
204+
"connectOverCDP", None, params
205+
)
204206
browser = cast(Browser, from_channel(response["browser"]))
205207
browser._connect_to_browser_type(self, None)
206208

@@ -222,6 +224,7 @@ async def connect(
222224
pipe_channel = (
223225
await local_utils._channel.send_return_as_dict(
224226
"connect",
227+
None,
225228
{
226229
"wsEndpoint": wsEndpoint,
227230
"headers": headers,

playwright/_impl/_cdp_session.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ def _on_event(self, params: Any) -> None:
2929
self.emit(params["method"], params.get("params"))
3030

3131
async def send(self, method: str, params: Dict = None) -> Dict:
32-
return await self._channel.send("send", locals_to_params(locals()))
32+
return await self._channel.send("send", None, locals_to_params(locals()))
3333

3434
async def detach(self) -> None:
35-
await self._channel.send("detach")
35+
await self._channel.send(
36+
"detach",
37+
None,
38+
)

playwright/_impl/_clock.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,46 +27,52 @@ def __init__(self, browser_context: "BrowserContext") -> None:
2727

2828
async def install(self, time: Union[float, str, datetime.datetime] = None) -> None:
2929
await self._browser_context._channel.send(
30-
"clockInstall", parse_time(time) if time is not None else {}
30+
"clockInstall", None, parse_time(time) if time is not None else {}
3131
)
3232

3333
async def fast_forward(
3434
self,
3535
ticks: Union[int, str],
3636
) -> None:
3737
await self._browser_context._channel.send(
38-
"clockFastForward", parse_ticks(ticks)
38+
"clockFastForward", None, parse_ticks(ticks)
3939
)
4040

4141
async def pause_at(
4242
self,
4343
time: Union[float, str, datetime.datetime],
4444
) -> None:
45-
await self._browser_context._channel.send("clockPauseAt", parse_time(time))
45+
await self._browser_context._channel.send(
46+
"clockPauseAt", None, parse_time(time)
47+
)
4648

4749
async def resume(
4850
self,
4951
) -> None:
50-
await self._browser_context._channel.send("clockResume")
52+
await self._browser_context._channel.send("clockResume", None)
5153

5254
async def run_for(
5355
self,
5456
ticks: Union[int, str],
5557
) -> None:
56-
await self._browser_context._channel.send("clockRunFor", parse_ticks(ticks))
58+
await self._browser_context._channel.send(
59+
"clockRunFor", None, parse_ticks(ticks)
60+
)
5761

5862
async def set_fixed_time(
5963
self,
6064
time: Union[float, str, datetime.datetime],
6165
) -> None:
62-
await self._browser_context._channel.send("clockSetFixedTime", parse_time(time))
66+
await self._browser_context._channel.send(
67+
"clockSetFixedTime", None, parse_time(time)
68+
)
6369

6470
async def set_system_time(
6571
self,
6672
time: Union[float, str, datetime.datetime],
6773
) -> None:
6874
await self._browser_context._channel.send(
69-
"clockSetSystemTime", parse_time(time)
75+
"clockSetSystemTime", None, parse_time(time)
7076
)
7177

7278

0 commit comments

Comments
 (0)